More Alternative Languages for WSH - Tips and Other Languages
(Page 5 of 5 )
In these last two articles, I’ve profiled what I would consider to be the most likely alternative languages for use in the Windows Script Host environment. This list is by no means comprehensive. There are dozens more WSH-enabled languages available for you to choose from. A Google search and a little research may reveal a version of your own favorite that is also WSH-enabled. Here’s a short list of some additional languages that I know of that offer WSH support.
As you’ve seen throughout my samples, many of these languages require you to specify an interpreter engine on the command line in order to run your scripts in the WSH environment. The tip I’m about to show you will allow you to double-click a script file or run it directly from the command line as you can with .vbs and .js files now.
You will have to modify the registry. As with any other registry changes, you should first create a backup in case something goes wrong.
I’m going to create a .pys (PythonScript) file extension. To begin, you’ll need to open Notepad and copy the text below. You may also download my file here.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT.pys]
@="pysfile"
[HKEY_CLASSES_ROOTpysfile]
[HKEY_CLASSES_ROOTpysfileScriptEngine]
@="Python"
[HKEY_CLASSES_ROOTpysfileShellEx]
[HKEY_CLASSES_ROOTpysfileShellExDropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"
[HKEY_CLASSES_ROOTpysfileShellExPropertySheetHandlers]
[HKEY_CLASSES_ROOTpysfileShellExPropertySheetHandlersWSHProps]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"
The first point of interest is the file extension of the first line (.pys). This should be changed to reflect the file extension that you wish to use.
The second point is the pysfile name. This can be changed to whatever you like. It should typically reflect your file extension. Be sure to change every instance. It appears in nearly every line! (Try using the Replace… command on the Edit menu).
Now change the value listed under ScriptEngine to reflect the proper script engine for your file type.
Finally, save your file with a .reg extension. Now when you double-click it, your file should add the appropriate changes to the registry. Your file type is now associated with the Windows Script Host!
The Windows Script Host provides a very flexible scripting environment. As you can see, it supports much more than just the VBScript that you are used to seeing. Don’t be afraid to take advantage of Python’s superb string handling or Perl’s regular expressions. Whatever your need or want, you now have the ability to use WSH in nearly any language you might choose. Until next time, keep coding!
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |