Script Tips
Pushing the Envelope
Simple script to push out administrative executables to remote computers.
Here's a quick trick where you can use Windows Script Host 5.6 to push
out scripts to a remote computer and have them execute locally on that
computer. It's a useful administrative trick!
Say you have a script named C:\Script.vbs on your computer, and you want
that computer to be copied to a computer named ClientB and executed. Nothing
could be simpler! Just use this code:
Dim oController, oRemote
Set oController = WScript.CreateObject("WSHController")
Set oRemote = oController.CreateScript("c:\Script.vbs", _
"ClientB")
oRemote.Execute
The oRemote has a Status property that tells you what's going on; to
be notified when the remote script has finished, just add this code:
Do While oRemote.Status = 0
WScript.Sleep 1000
Loop
WScript.Echo "Remote script finished!"
It's that easy. Now you can push out scripts to execute in a distributed
fashion (sounds fancy, doesn't it?) and even keep track of when they're
finished. It's all built into WSH 5.6 and it only takes a few lines of
code to operate!
About the Author
Don Jones has more than a decade of professional experience in the IT industry. He's the author of more than 30 IT books, including Windows PowerShell: TFM; VBScript, WMI, and ADSI Unleashed; Managing Windows with VBScript and WMI; and many more. He's a top-rated and in-demand speaker at conferences such as Microsoft TechEd and TechMentor, and writes the monthly Windows PowerShell column for Microsoft TechNet Magazine. Don is a multiple-year recipient of Microsoft's Most Valuable Professional (MVP) Award with a specialization in Windows PowerShell. Don's broad IT experience includes work in the financial, telecommunications, software, manufacturing, consulting, training, and retail industries and he's one of the rare IT professionals who can not only "cross the line" between administration and software development, but also between IT workers and IT management.