Windows Script Host also has the ability to run scripts on other computers. However, this function has not been very popular, and most likely due to the fact that demands too much of the preparatory activities and in return provides little opportunity. But I still talk about this method, because he might be useful.
So, to run the script on another computer using WSH, we need to do the following:
Administrator rights on the remote computer. It goes without saying, is - required for nearly all other methods listed at the start of this article.
- Allow WSH Remote Scripting creating the registry string value Remote equal to "1" in the registry key HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows Script Host \ Settings
- Because of an error described in the Microsoft Knowledge Base article with the number 311269, on systems with Windows XP may need to execute the command wscript-regserver
- If you're using a firewall, then it should be allowed to access DCOM. And this must be done not only on the managed computer, but also on where you want to run the script.
- On Windows XP Service Pack 2 and above, you must change the security settings DCOM. This can be done using Group Policy. In node Computer Configuration \ Windows Settings \ Security Settings \ Local Policies \ Security Options should be set permissions as follows:
- DCOM: Machine Access Restrictions in Security Descriptor Definition Language (SDDL) syntax
By the Group to Anonymous Logon and Everyone permissions Allow Local and Allow Remote Access - DCOM: Machine Launch Restrictions in Security Descriptor Definition Language (SDDL) syntax
Issue the Administrators group permission Allow Local Launch, Allow Remote Launch, Allow Local Activation, Allow Remote Activation
Group Everyone - Allow Local Launch, Allow Local Activation
Well, after all these procedures, you can try to run your script on another computer.
A sample script that uses this technology:
WSH remote scripting (VBScript)
Code:
Set objController = CreateObject ( "WshController")
Set objRemoteScript = objController.CreateScript ( "C: \test.vbs", "PC5") WScript.ConnectObject objRemoteScript, "remote_"
objRemoteScript.Execute
Do While objRemoteScript.Status <> 1
WScript.Sleep 1000
Loop
MsgBox "Script complete"
Sub remote_Error
Dim objError
Set objError = objRemoteScript.Error
WScript.Echo "Error - Line:" & objError.Line & _
", Char:" & objError.Character & vbCrLf & _
"Description:" & objError.Description
WScript.Quit -1
End Sub
In his second line, as parameters to the function CreateScript the path to the script file that will be executed on a remote computer and the actual name of this computer.
Bookmarks