Creates a WshRemote object.
object.CreateScript(CommandLine,[MachineName])
The CreateScript method returns a handle to an instance of a WshRemote object. The path part of the script name does not need to be local it can refer to a script on a network share. This makes it possible to sit at one computer system, retrieve a script from another computer system, and run it on a third computer system. If a machine name is not provided, the remote script object runs on the controller computer system (this is the default). If a machine name is provided, the remote script object runs on the named computer system. The CreateScript method establishes a connection with the remote computer system and sets it up to run the script, but the script does not actually start until you call the Execute method of the WshRemote object.
The following example demonstrates how the CreateScript method of the WshController object is used to create a WshRemote object (an instance of a remote script).
Dim Controller, RemoteScript
Set Controller = WScript.CreateObject("WSHController")
Set RemoteScript = Controller.CreateScript
("test.js", "remoteserver")
WScript.ConnectObject RemoteScript, "remote_"
RemoteScript.Execute
Do While RemoteScript.Status <> 2
WScript.Sleep 100
Loop
WScript.DisconnectObject RemoteScript
Sub remote_Error
Dim theError
Set theError = RemoteScript.Error
WScript.Echo "Error " & theError.Number & " - Line: " & theError.Line & ", Char: " & theError.Character & vbCrLf & "Description: " & theError.Description
WScript.Quit -1
End Sub
var Controller = WScript.CreateObject("WSHController");
var RemoteScript = Controller.CreateScript
("test.js", "remoteserver");
WScript.ConnectObject(RemoteScript, "remote_");
RemoteScript.Execute();
while (RemoteScript.Status != 2) {
WScript.Sleep(100);
}
WScript.DisconnectObject(RemoteScript);
function remote_Error()
{
var theError = RemoteScript.Error;
WScript.Echo("Error " + theError.Number + " - Line: " + theError.Line + ", Char: " + theError.Character + "\nDescription: " + theError.Description);
WScript.Quit(-1);
}
CreateObject Method | CreateScript Method | WshRemote Object | Execute Method