indows Script Host (WSH) version 5.6 is the latest release of the script host for 32-bit Windows systems. As a native component of Microsoft Windows XP and the upcoming Windows Server 2003, WSH 5.6 provides the environment for creating and hosting scripts that can perform both local and remote system administration tasks. WSH 5.6 also runs on Windows 2000, Windows Me, Windows 98, and Windows NT 4.0. If you're using one of these older systems, an add-on version of WSH 5.6 can be downloaded from the scripting section of the MSDN Web site at Although WSH comes with a rather compact object model to facilitate typical Windows administrative tasks, it provides nearly complete access to any imaginable task in Windows through script. WSH allows you to run scripts that use Windows Management Instrumentation (WMI) and Active Directory Services Interface (ADSI) functions. In addition, it provides programmable objects representing the system shell, the system registry, and the file system, in addition to an infrastructure to control remote scripts and secure your local system against malicious programs. WSH is definitely evolving to integrate with .NET, but full integration is still a little way off. In this article I'll describe the new features in WSH 5.6. You'll also see how .NET and scripting work together. In particular, I'll explore some of the techniques you need to set up WSH scripts that call into components based on the .NET Framework. Finally, the sidebar \"The Road to Scripting in .NET\" illustrates a component that compiles and executes C# code on the fly in much the same way as WSH does with VBScript and JScript sources.
In particular, the tags in the WSF schema let you include external files and import constants from type libraries. The XML format is also the key to running different languages in the same script. WSH, in fact, has the ability to host multiple scripting languages and also supports calls from one language to functions written in another language. WSH 5.6 expands the types of metadata you can associate with a script. New tags have been introduced to create usage information and to define command-line argu- ments. One consequence of this improvement is that WSF scripts running under the control of WSH 5.6 don't need to use any kind of boilerplate code to detect the / switch on the command line for the correct way to execute the script. The WSH 5.6 object model has a new method called ShowUsage, which can be called programmatically to show a pop-up window describing the usage of the script. This method is automatically invoked by the WSH runtime when the script has the / switch. All the rest happens automatically, thanks to the WSH 5.6 runtime. I'll discuss ShowUsage and other benefits of metadata later.
Verifying a script is the process that determines whether the script that you are about to run is coming from a trusted source. Prior to WSH 5.6, you used the signcode.exe tool to encrypt script files. This tool is not strictly part of any version of the Microsoft Windows operating system. Rather it is part of the Microsoft Windows 2000 Platform SDK and is a separate download. The WSH 5.6 object model ships with a new object called Scripting.Signer that does the same thing. The following simple script signs a file using the specified certificate and store:
The WSH core (wscript.exe) is a relatively simple Win32 application that hosts the Windows Script engines and acts a kind of super proxy between the .vbs or .js user file and the script engine. In the past, a lot of people applied the same model to their applications making them customizable and extensible. The question you may be asking now is what's going to change in this area with the advent of .NET Scripting has very little to do with .NET for two good reasons. First and foremost, WSH relies completely on COM. Second, the advantages you get from .NET languages over scripting languages are substantial in terms of performance and programming ease. Whenever you can use a .NET language instead, there's no question about what's better. The .NET Framework comes with a set of language engines that applications can host in much the same way as the VBScript and the JScript engines. These new engines are freely redistributable along with the rest of the framework. At this time, the two script engines that the .NET Framework provides run Visual Basic .NET and JScript .NET. In addition, a third engine is in the works for the .NET intermediate language (IL). This engine would be able to load precompiled IL code but not compile from sources. This new Script for the .NET Framework infrastructure has a number of advantages over the Windows Script engines. First, you have full access to the entire .NET platform. In other words, you are no longer forced to build a tailor-made object model in your applications just to allow for scripting. In .NET, the application is inherently programmable in the sense that any constituent public class is accessible without intermediate proxies. However, you can control what objects are effectively reachable via script and you can make the scripts run in a kind of secured sandbox. The languages you use to script .NET applications are the same first-class languages you use for writing them. They provide advanced features such as strong typing, early binding, and, of course, compiled code. In addition, Script for the .NET Framework can rely on the debugging and editing features of Visual Studio for Applications (VSA). To start using a language engine, you first create an instance of it, add some code, and then add the object model that the script is based upon. Objects are not attached to the engine through living instances as they were with the Windows Script engine. Instead, you need to specify the type and name in order to script the object. Only when the script executes and an instance of that object is needed will the engine call you back to obtain a usable instance for that kind of object. The interface involved with the setup of the engine is IVsaEngine. The interface for callbacks is IVsaSite. The language engines also support the ability to add references to .NET classes by creating an item in the engine with the full name of the involved assembly. In this way, all the types in the assembly are available to the script. When WSH is updated for .NET it is expected to be an application based on the Script for the .NET Framework engine and the new object model is heavily based on the VSA engine. What you can expect in the future of WSH, far beyond today's upgrade, is a shell-level environment that knows how to work with any .NET language from JScript .NET to Visual Basic .NET, and from J# to C#. Any of these languages will become just another \"script\" language supported by WSH. Why then would you use WSH instead of regular Windows Forms applications Windows Forms are, and will be, full-fledged applications distributed through compiled code. It is expected that WSH applications for .NET will be script-like applications distributed through source code that will be compiled on the fly. Each of them will have its own use and gain its own space. For more information about Visual Studio for Applications see Information about Script for the .NET Framework can be found at Particularly helpful for understanding the big picture and getting started with some sample code are the articles in the Scripting Clinic column on MSDN Online.
Windows Script Host (WSH) is unable to execute VBScript scripts. This can occur if the scripting host is disabled (which is unusual), or if the installation is broken. A sign of this problem is a message like
The printer uses the Ghostscript PDF converter.Ghostscript is an open source program that is able to convert PostScript to PDF files. It is distributed under the GNU General Public License. More information about Ghostscript is available here.
I must say I switched Internet Security programs to AVAST! on TU Apr26th and love it so far. Highly recommend looking into AVAST! ver 6.0 at CNET downloads - free. The anti-virus program is free, but everything else costs about $30US for a year. WORTH IT Love the options settings flexibilityuser friendly windows.
We've talked at length about automating Windows applications through COM/OLE, using the win32ole library. But not all applications expose themselves (so to speak) to such automation. The Windows Script Host can automate the activation of windows, and the sending of keystrokes. This may sometimes be all that you need to get the job done.The Windows Script Host (WSH) has been part of the Windows operating system since Windows 98. You can use WSH's Shell object (via COM/OLE) to send keystokes to windows.First, require the win32ole library:require 'win32ole'Now we'll create an instance of the Wscript Shell object:wsh = WIN32OLE.new('Wscript.Shell')To send keystrokes to a window, you must first activate the window, bringing it to the forefront. This can be done with the Wscript Shell's AppActivate method, which returns true if the window was successfully activated, and false otherwise. The AppActivate method takes the window title text as it's argument:wsh.AppActivate('Title')The string passed to the AppActivate method can be a partial, but must be the start or ending of the window title. The method is not case sensitive, and does not accept regular expressions. To quote Microsoft: \"In determining which application to activate, the specified title is compared to the title string of each running application. If no exact match exists, any application whose title string begins with title is activated. If an application still cannot be found, any application whose title string ends with title is activated. If more than one instance of the application named by title exists, one instance is arbitrarily activated.\"Once you have the window activated, you may use the Wscript Shell's SendKeys method to send keystrokes to the window. The Send