Running Scripts on Remote Computers

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

The WshController object provides you with the ability to run scripts on remote computers. The WshController object has a single method, CreateScript, which returns a WshRemote object.

In turn, the WshRemote object can then be used to run the worker script. The worker script is not run as a result of the call to CreateScript. Instead, the WshRemote object Execute method is used to actually run the script on the remote computer.

The script in Listing 3.42 runs the hypothetical worker script MapNetworkDrive.vbs on the remote computer, RASServer01. Although the location of the worker script can be specified using either a local file path or a UNC path, because no path is specified in Listing 3.42, this means the worker script must be located in the same directory as the controller script.

Listing 3.42   Running a Local Script on a Remote Computer

1 2 3 4 5 6 7 8 9 10 11 
strRemoteComputer = "RASServer01" strWorkerScript = "MapNetworkDrive.vbs" Set objWshController = WScript.CreateObject("WshController") Set objRemoteScript = _ objWshController.CreateScript(strWorkerScript, strRemoteComputer) objRemoteScript.Execute Do While Not objRemoteScript.Status = 2      Wscript.Sleep(100)      Wscript.Echo "Remote script not yet complete." Loop

Note

  • Remote access is not an interactive process, which means that remotely run scripts cannot display any GUI elements on the remote computer. If you run a remote script that displays a GUI element, the script might fail or produce indeterminate results. For example, suppose your script displays a message box that the user must respond to. Because the script runs in a hidden window, the user will never be able to see, and thus never be able to respond to, that message box. As a result, the script will hang, waiting for user input that will never be provided.

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

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