Scripts

A logon script is a batch (BAT) or executable (EXE) file that runs any time the user logs on to the network from any of the networked workstations. A logon script may contain operating system commands (for example, the ones that restore network connections or run applications). Logon scripts may also specify the environment variables, such as PATH or TEMP.

Windows 2000 has made an improvement in this area—Windows Script Host (WSH) 2.0 WSH 2.0 is capable of creating simple, but flexible and powerful scripts to automate network administration. Because WSH is language-independent, you're free to select any scripting language you prefer: Visual Basic Scripting Edition (VBScript), JScript and Perl. WSH also supports COM, allowing you to enjoy the advantages of new technologies such as Windows Management Instrumentation (WMI) and Active Directory Services Interface (ADSI).

Using WSH in Logon Scripts

We won't dive into the details here; instead, let's look at a small example of the logon script, which edits the registry (after all, this is a book on the registry). Most end users are afraid of registry editing procedures. Because of this, you can write a small logon script for these users that customizes the system registry. WSH provides a convenient and easy technique for manipulating the registry using the following methods: regRead, regWrite, and regDelete.

An example of the code provided below changes the proxy settings stored in the registry under HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer. First of all, you need to read these settings using the regRead method. Then, using the regWrite method, you can overwrite the existing value (for example, replace the existing value by NEWPROXY: 80). Finally, you need to make sure that the changes you've introduced are correct. This is done using the regRead method:

 ...    sub regProxy      prefix = _         "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\"         WScript.Echo "Old ProxyServer settings:" & wshShell.regRead (prefix & _          "ProxyServer")         wshShell.regWrite prefix & "ProxyServer", "MYPROXY:80"         WScript.Echo "New ProxyServer settings:" & wshShell.regRead(prefix & _          "ProxyServer")    end sub    ... 



Windows XP Registry
Linux Enterprise Cluster: Build a Highly Available Cluster with Commodity Hardware and Free Software
ISBN: N/A
EAN: 2147483647
Year: 2000
Pages: 144
Authors: Karl Kopper

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net