I recently upgraded several remote computers to Windows XP Professional Edition. When I tried to use Windows Script Host (WSH) 5.6's new WshController object to run a local script on the remote XP Pro computers, I received the error message Microsoft VBScript runtime error: ActiveX component can't create object. How can I get the WshController object to work?
Unfortunately, XP Pro shipped with a configuration bug in which WSH 5.6 fails to set up properly. Based on my testing, the problem appears to be limited to the WshController object. To resolve the problem, you need to run the command
C:\> wscript -regserver
Another possibility is that you haven't enabled the WshController object, which is disabled by default. To enable this object, you must add a value entry to the HKEY_LOCAL_ MACHINE\SOFTWARE\Microsoft\Windows Script Host\Settings registry subkey on the target computer. Open this subkey and click New, String Value on the Edit menu. Enter the value name Remote and a data value of 1. You don't need to restart the target computer for the new setting to take effect.
In addition to fixing the bug and enabling the WshController object, you might want to verify that you've met several WshController requirements to avoid additional stumbling blocks. Make sure that
- you've installed WSH 5.6 on the source and target remote computers.
- you hold Administrator privileges on the target remote computer.
- you've passed the target remote computer's name to the WshController object's CreateScript method.
- the script passed to the WshController object's CreateScript method doesn't interact with the UI. In other words, you need to avoid using WScript.Echo, STDIO, WshShell::Popup, MsgBox, InputBox, and other UI functions in the script that the target remote computer will run.
Listing 1 and Listing 2 contain boilerplate scripts that you can use to test the WshController object after you've made the necessary changes to your computers and code. Listing 1, WshControl.vbs, is the control script; Listing 2, WshRemote.vbs, is the remote script. The control script creates a WshController object, connects to the target remote computer, copies the remote script to the remote computer's memory, launches the remote script, and monitors the remote script's execution. If the WshController object is working properly, the remote script creates the text file wshwashere.txt, which contains the line The quick brown fox jumps over the lazy dog's back.
To use the test scripts, copy them to the C:\scripts directory and modify the value of strComputer in WshControl.vbs to match your target remote computer's name. To run WshControl.vbs, use the command
On the script's completion, the wshwashere.txt file will be on the target remote computer. To learn more about the WshController object, see Microsoft's Windows Script (WS) 5.6 documentation. You can download this documentation at http://download .microsoft.com/download/winscript56/install/5.6/w982kmexp/en-us/scrdoc56en.exe.