Windows Scripting Or WSH
Windows Script Host (WSH), can be thought of in the same way as old DOS batch files,
because it allows you to directly script and automate parts of the core operating
system using plain text files. By using these scripts you can automate anything from
the Windows registry, through to files and shortcuts,through to network printers and
shares, and because of the extensible nature of the language there is practically no
limit to what it can do.
WSH is really made up of three main components:
-The core host that ties all the pieces together.
-The scripting engines that provides the scripting languages, such as VBScript,
JScript and PerlScript.
-The Scripting Hosts that actually execute the scripts, two are shipped as standard
WSCRIPT.EXE [a Windows GUI version] and CSCRIPT.EXE [a text mode command-line version].
The advantage of the Windows Script File (.WSF) is that it allows you to use a combination of scripting languages within a single file.
A collection of scripts for automating certain tasks.So if anyone wants to jump straight to creating and using the script, you can simply type it in and save it as a file. For those hungry for detail, we’ll be explaining each script as it comes. Hopefully, this should be help enough for you to start writing your own scripts.About the only thing you will need to create and run the scripts is the trusty Notepad. Enter the script text and save the file with a .vbs extension. Whenever you want to use the script, simply double-click the file to execute your script. That said, let’s get down to the scripts.
Examples :
Scripts alone can be so powerful that one can even create viruses using it: the dreaded ‘ILOVEYOU’ virus is, at its core, just a text file containing a script. Don’t despair-creating and executing scripts in Windows doesn’t require you to install any software or compile any¬thing; instead, it requires code-a lot of code. OK. despair a bit, but in the end it’ll be worth it.
1) Delete files :
You probably saw this coming after the last one: you can use the “deletefile” object to delete any files.
This is useful when you want to make sure that cer¬tain cm:ectories are empty or certain files are deleted
before you shut down Wmdows, or simply to clear out all tem¬porary files.
The script is like ;
SetFSO= CreateObject(”Scripting.FileSystemObjec t”)
FSODeleteFile “C:\testl \temp.doc”
Rather self~lanatory. You’re already familiar with the first part by now; the next line has an easy to understand function, “FSO.DeleteFile”, fol¬lowed by the path to the folder or file you want to delete.
If you want to nuke the entire directory, use the … variable to include all files in the directory specified in the script.
2) Map a network drive using a shortcut :
Ever wanted a simple shortcut to map your network shares to a drive? You can do so using this script.Remember that you can also add as many drives you want to map, similar to WSHShell.Run
Here it is ;
Set WSHNetwork = WScript.CreateObject(”WScript.Network”)
WSHNetwork.MapNetworkDrive”5:”, “\ \network\share 1″
WSHNetwork.MapNetworkDrive-r:”, “\ \network\share 2″
WSHNetwork.MapNetworkDrive”U:”, “\ \network 2\share 3″
Again, the first line asks WSH to declare the “WSHNetwork” object. As mentioned before, since we are making changes to the network subsystem-a network drive in this case-we’ll need to declare it, like we have done in the first line. Further down, we see “WSHNetwork” using the “MapNetworkDrive” function, this is the actual command for creating a network drive. Take note that the drives them selves are in their own set of quotes followed by the network shares. Similar to the Run function earlier, the drives will be mapped in order from top to bottom.

















