Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Running Scripts on Remote Computers

Microsoft® Windows® 2000 Scripting Guide

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


strRemoteComputer = "RASServer01"
strWorkerScript = "MapNetworkDrive.vbs"
Set objWshController = WScript.CreateObject("WshController")
Set objRemoteScript = _
objWshController.CreateScript(strWorkerScript, strRemoteComputer)

Do While Not objRemoteScript.Status = 2
 Wscript.Echo "Remote script not yet complete."


  • 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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft