Remote execution

M

M. Eteum

Is there any example of remote execution from Windows XP to/from Windows
2000 and 2003? WMI? WSH? MSH?

Thanks

M.
 
M

Martin Zugec [MVP]

Easiest way for interactive remoting is:

a.) PsExec from SysInternals
b.) /Node switch in WMIC

Martin
 
M

M. Eteum

Martin said:
Easiest way for interactive remoting is:

a.) PsExec from SysInternals
b.) /Node switch in WMIC

Martin
I did try the /Node switch in WMIC but I have no idea how to execute a
script or an exe file reside on the remote node. Do you have any
example? Thanks.

M.
 
O

Office Linebacker

I am not sure if this is what you are looking for but, here is something I
use to start remote apps. Replace "webserver" with your machine name.

Bill James, MCSE
Enterprise Directory Service

Code:

strComputer = "webserver"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2:Win32_Process")

Error = objWMIService.Create("notepad.exe", null, null, intProcessID)
If Error = 0 Then
Wscript.Echo "Notepad was started with a process ID of " _
& intProcessID & "."
Else
Wscript.Echo "Notepad could not be started due to error " & _
Error & "."
End If
 
M

M. Eteum

Office said:
I am not sure if this is what you are looking for but, here is something I
use to start remote apps. Replace "webserver" with your machine name.

Bill James, MCSE
Enterprise Directory Service

Code:

strComputer = "webserver"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2:Win32_Process")

Error = objWMIService.Create("notepad.exe", null, null, intProcessID)
If Error = 0 Then
Wscript.Echo "Notepad was started with a process ID of " _
& intProcessID & "."
Else
Wscript.Echo "Notepad could not be started due to error " & _
Error & "."
End If
I tried it but no sign that it is executed. It worked on the local
machine by replacing the "webserver" to "." . I even when I monitor the
remote machine use terminal services, logged in as myself, and watch the
task manager, I don't see a notepad.exe process. Any idea?
 
M

Marty List

M. Eteum said:
I tried it but no sign that it is executed. It worked on the local
machine by replacing the "webserver" to "." . I even when I monitor the
remote machine use terminal services, logged in as myself, and watch the
task manager, I don't see a notepad.exe process. Any idea?


By default, Task Manager will only show you some processes. You need to be an
admin, and you need to enable "Show processes from all users" near the bottom of
the window.

If you're set on using WMI, read this:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/creating_processes_remotely.asp

If you want to use WSH, read this:
http://msdn.microsoft.com/library/en-us/script56/html/wslrfRemote_WSHObject.asp
http://msdn.microsoft.com/library/e...ptsRemotelyRunningScriptOverThereFromHere.asp


This is a complicated topic, explain in detail what you are trying to
accomplish.
 
G

Gerry Hickman

Hi,

A few things to note:

1. You can certainly start a process from WMI on a remote machine. The
Notepad example above is a bit horrible, because it leaves the process
running but invisible.

2. If the user gets a PID back from the calling script they need to
check for that PID in the task list on the remote box. If they didn't
get a PID then there's no point logging on with terminal services etc. I
personally use Microsoft PVIEWER to check processes on remote machines
and it's pretty reliable when used with processes started from WMI.

3. Starting a process may be easy, but how will you stop it, or know
that it's stopped? May need to monitor process list and send a terminate
command...

4. PSEXEC can do two way interactive StdIn/StdOut back to the remote
console. I don't think WMI can do this. This is a major factor to
consider; how will you monitor console I/O with WMI??

5. It's almost certain your remote process won't be able to access any
network resources unless you pass plain text user and password which is
very bad for security, especially if the password ends up in a script file!

6. The WshRemote solution has some advantages in that you can get the
console I/O, but it requires a registry key to allow remote execution
and basically you are running the script on the REMOTE box, you are NOT
running it from the Admin console after the call, so it's not as nice as
the way WMI interacts with remote boxes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top