G. Born: Windows Scripting Host Tutorial Preface Introduction Why I wrote this book? How to use this book? A few other remarks 1 Introduction into WSH What is the Windows Script Host? What can we do with WSH scripts? A few remarks about JScript/VBScript How to install WSH? How to check whether WSH is installed? Install WSH in Windows 98 Windows 95/Windows NT 4.0 How to create and use scripts Let's create our first (VBScript) script Same sample, but now in JScript How to execute WSH scripts? Launch a script in Windows Using the Windows Command Prompt to execute scripts Set the script properties How to submit parameters to a script? Passing arguments in Cscript.exe Remarks about the scripting samples shipped with Microsoft Windows 98 2 Development Tools A few tips to edit scripts How to create a script? Edit existing script files?
IV Define your own Edit script command Script Editors EditPlus PrimalSCRIPT script editor Other editors The OLE/COM Object Viewer Using the Object Browser Installing/uninstalling ActiveX controls Uninstalling OCX files Script debugging Trace your programs Using the Microsoft Script Debugger Microsoft Script Debugger commands Execute a script step-by-step? Using the Step Over and Step Out mode Using breakpoints Showing the Call Stack Show interims values using the Command Window 3 Simple Dialogs in WSH Using the Echo method Using Echo in VBScript Echo and the Windows Command Prompt Using the Echo method in JScript How to get a line feed within a dialog box? Using MsgBox in VBScript Define the buttons and the icon Which button was clicked in a dialog box? Using the Popup method Using Popup in JScript? Can we use Popup also in VBScript?
4 Working with WSH objects Using the WScript object Displaying WSH and script properties Retrieving properties in VBScript Retrieving properties in JScript Retrieving the script engine's properties Accessing script arguments Two solutions in VBScript A solution in JScript Accessing environment variables Global remarks How to access environment variables per script? Using environment variables in VBScript How to read environment variables in JScript How to set environment variables Deleting environment variables Expanding environment variables Get and release objects Create objects CreateObject or GetObject? Using DisconnectObject Execute other programs from scripts Remarks about the Run method Launch the Windows Editor from VBScript How to call the Windows calculator from JScript? A few remarks about the Quit method Wait for process termination and check exit codes Using Run to execute MS-DOS commands 5 User Input in scripts User input in VBScript
VI User input in JScript JScript-user input using a second script Internet Explorer for JScript user input Implementing an InputBox function in HTML Call the function within the HTML document The InputBox implementation for JScript An InputBox ActiveX control 6 Using forms User Forms with Internet Explorer Creating a Dialog using showModalDialog Using Internet Explorer for dialogs Creating Forms using Internet Explorer The HTML code for the form DHTML code to control your form A WSH script to use the form A JScript WSH script to access the form Form input using a CallBack function Using ActiveX controls as forms Using an ActiveX control for an about dialog box Using the About dialog from a WSH script Using a form for user input Creating the form using VB 5 CCE How to define global variables to keep user input values? How to implement the form handling methods? How to use the ActiveX control in a WSH script? Using the form in JScript Implementing a password input dialog A WSH script using the password input 7 Shortcuts A few Basics
Creating a Shortcut with CreateShortcut Creating a Shortcut to the Current Script File The JScript Implementation Using the SpecialFolders object Displaying all Special Folders Entries The JScript Implementation Finding the Path to a Special Folder The JScript Implementation Creating a Shortcut on the Desktop The JScript Implementation Creating a Shortcut in the Start menu The implementation in JScript Creating Shortcuts with Parameters The JScript Implementation Creating a Shortcut to a Website The JScript Implementation 8 Extended WSH features Using Network Resources User name, Domain, Computer name The JScript Implementation Mapping Printers Control and Maintenance of Printer Mappings Mapping a Printer in VBScript Run-time Errors Run-time Error Handling in VBScript The JScript Implementation Printer Mapping in JScript 5.0 with Error Trapping Executing a Script within Each Login Listing all Mapped Printers The JScript Implementation Mapping Network Drives
VIII The JScript Implementation The JScript 5.0 Implementation Accessing the Windows Registry Registry Access using WSH Registry Access with VBScript The Jscript Implementation Run-time Error Handling for Registry Access Checking the Existence of a key in VBScript Using the WSHKeyExist1-Method Using the WSHKeyExist1 Method in VBScript The Jscript Implementation Changing the Windows Install Path Hiding the Last User Name at Login Retrieving the Workgroup Name The JScript 5.0 Implementation 9 Using file system commands The FileSystemObject object model Create a FileSystemObject object Create an object reference in VBScript Create an object reference in JScript Accessing FileSystemObject methods Accessing drives How to list all drives on a machine How to implement the sample in VBScript How to implement the sample in JScript Showing drive properties Retrieving drive properties in JScript Accessing files and folders Showing all sub-folders of a folder The JScript implementation to list subfolders Recursive folder processing
Create, move, rename and delete folders How to create a new folder How to retrieve the parent folder? Rename, copy or move a folder Deleting folders Implementing the sample Folder1.vbs Folder1.js : The implementation in JScript List all files within a folder The file list sample, implemented in JScript Accessing file attributes and -date The implementation in VBScript The implementation in JScript Just another problem with CreationDate Copy and delete files Sample: Implementation in VBScript Sample: Implementation in JScript How to create backup copies using scripts? Accessing text files Read from a text file The VBScript implementation The JScript implementation Writing into a text file The VBScript implementation The JScript implementation Append to a text file A sample in VBScript Implementing the sample in JScript File dialogs Show a dialog to select a folder Using a file dialog 10 ActiveX controls programming
X VB 5 CCE the basics What is VB 5 CCE? Create a new ActiveX-Project Introduction into VB 5 CCE About projects, classes, modules and properties The code window The properties window Inserting controls into a Form Creating an OCX file Create an install file for an ActiveX control How to get information about objects? Create an object description for the object browser A project sample ActiveX samples Implementing the WSHKeyExist1 method A Wait method for Scripts A method to play sounds within a script WSHShell - and WSHAppActivate methods Implementing the WSHShell method Implementing the WSHAppActivate method Testing WSHShell and WSHAppActivate The SendKeys problem Implementing a WSHSendKeys method Remarks about the WSHSendKeys method Remarks about the WSHSendKeys implementation Sample 1: Launch and terminate Calc.exe Sample 2: Manipulating two applications using WSHSendKeys Sample 3: Clipboard handling using WSHSendKeys Using WSHSendKeys to create a new user account How to handle windows? The WSHFindWindow method
The WSHIsWindow method The WSHIsIconic method The WSHShowWindow method The WSHSetForegroundWindow method The WSHMoveWindow method The WSHFlashWindow method Sample 1: Manipulate a window Sample 2: A moving and flashing window Shutdown Windows 95/98 using a script A script using the WSHExitWindows method 11 WSH and Microsoft Office Using Microsoft Excel The Excel object model A sample to access Excel Set the window properties The implementation in VBScript An implementation in JScript Create an Excel worksheet and add the content The VBScript implementation The JScript Implementation Writing WSH information into a worksheet The VBScript Implementation The JScript implementation Load an Excel XLS file and read the data Implementing the sample in VBScript An implementation in JScript Importing a CSV file in Excel How to import CSV files into several columns? Using Microsoft Word The Word 97 object model Sample 1: Access Word from a script