Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I run a command-line utility (diskpart) on a remote machine?

2,323 views
Skip to first unread message

Dave

unread,
Jul 14, 2003, 8:49:09 PM7/14/03
to
Basically, I'm trying to run the diskpart utility on a
remote Windows 2000 machine. I'm a newbie, so here is what
I have so far:

set objWMIService = GetObject("winmgmts://" & Computer)
set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "C:\Program Files\Resource Kit\diskpart \s
listdisk.txt"

First off, I'm guessing that this tidbit of code will try
to run diskpart on the local machine. How can I bind
objShell to the remote machine (Computer)?

Thanks.

-Dave

Tom Clark

unread,
Jul 15, 2003, 6:17:09 AM7/15/03
to
Dave, this should go on the WMI news group but while I'm here...

You seem to be a bit mixed with windows scripting host and WMI. WSH 5.6 will
allow you to run script files on a remote machine but only script files
(wsf, vbs etc.). To run a program remotely you'd need to WMI. The following
few lines show how you can do this although I've found that detecting when
the remote process has completed is not always successful.

Set refWMI =
GetObject("Winmgmts:{impersonationLevel=impersonate}!\\SERVERNAME")
Set refProcess = refWMI.Get("Win32_Process")
refProcess.Create "c:\..\iexplore.exe", null, null, intHandle

The preceding code will create an instance of iexplore on the remote machine
which will be running in the security context of the person running the
script. The variable intHandle is passed the PID of the process (which can
be seen in Task Manager) so you can detect its completion or kill it. The
path to the executable has to be a full local path and generally, no-one
will be able to see the remote process running except through task maanger
(I found on Windows 2000 you could sometimes see the internet explorer
window).

Hope this helps and good Luck.

"Dave" <pow...@fastmail.fm> wrote in message
news:058701c34a6a$e6b2c450$a301...@phx.gbl...

0 new messages