?
Solved

Is it possible to have a WMI script create and write a vbs script on a remote computer then run it

Posted on 2011-03-21
3
Medium Priority
?
230 Views
Last Modified: 2012-05-11
Is it possible to have a WMI script create and write a vbs script on a remote computer then run it. Purpose of this script is to monitor virtual desktop environments. We would like to eliminate any network drive dependence to get the vbs file.
0
Comment
Question by:williamfl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Expert Comment

by:virtualmess
ID: 35183976
If I was going to do this, I'd most likely do it through a combination of VBScript and the Microsoft Sysinternals PSEXEC utility.  Attached is a (tested and working in my environment) sample VBScript which:

Takes as input a PC name.
Generates a customized DOS batch script based on the PC name.
Copies the generated script to the remote machine.
Uses PSEXEC to run the script on the remote machine.

In theory, you could replace the code to generate the script with code to generate a VBScript, PowerShell script, etc.  

Running the attached script with administrator credentials (on both the source and target machines), it worked without error going from a Windows XP SP3 box on a Windows domain to another Windows XP system on the same domain.

Your mileage may vary but this should get you pretty close.

expdemo.vbs
0
 
LVL 6

Expert Comment

by:Lee_YCP
ID: 35184114
You should note that PSEXEC may be stripped by AntiVirus based on your settings and end up with a file that copies to the destination, but contains 0KB data and hence does not run.
0
 
LVL 1

Accepted Solution

by:
virtualmess earned 2000 total points
ID: 35184865
If you really want to stick with JUST WMI, this example would work also.  It was interesting to figure out a way to sneak a text file onto a remote machine (none of the examples I found would quite do it).

The attached example uses the vanilla DOS "echo" command to create a script line-by-line on the target machine, then runs it using WMI.  Since the echo command treats certain characters as "special", the script has to "clean up" the lines of code before transmitting them, or the echo command will garble them.

Still, this is a WMI-only example of how to do what you are looking for.  I've only tested it with simple DOS examples, but I see no reason it couldn't pipe a VBScript, Perl Script, or PowerShell script to the remote machine using the same method.  It might require the cleanup routine to be modified, but that should be about it.

wmitest.vbs
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question