Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

January 09, 2002 12:00 AM

Rem: Getting the WshController Object to Work

Windows IT Pro
InstantDoc ID #23607
Rating: (3)
Downloads
23607.zip

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

C:\scripts\wshcontrol.vbs

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.

Related Content:

ARTICLE TOOLS

Comments
  • Brendan
    6 years ago
    Mar 21, 2006

    I am trying to run this from a xp workstation that is joined to a w2k3 domain. I have performed the regserver on the target and from the workstation that i am executing from and also added the registry key. I am getting a permission denied error on the Set objRemoteScript line. No errors in event logs. Any ideas?

  • jlechner
    8 years ago
    Jul 27, 2004

    Yeah works great once you Check that Registry setting even on Win 2K

  • Israel
    8 years ago
    Jul 20, 2004

    Great

  • Dan
    8 years ago
    Jul 01, 2004

    Excellent article, it worked the second time I tried it. Since it wasn't clear I ran the wscript -regserver on the target machine. You need to run it on the machine that your launching the control script from.

  • Borun
    9 years ago
    Sep 29, 2003

    Just Awesome! Solved our problem easily...

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.