Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting remote processes in a Windows network

I have several slave machines and a master machine which together run a distributed application. Processes on each slave machine have to have a GUI and network access (I think it would be called an interactive process then). For ease of use it would be nice if the master machine could start/stop the processes on those slave machines.

My first idea was to use WMI and the Win32_Process class to start a remote process but upon further investigation it was reveiled that processes started this way are non-interactive and isolated, and thus cannot have any GUI. A note says that one can use Win32_ScheduledJob.Create to create a remote interactive process, but it runs under the LocalSystem account which I would like to avoid (also I couldn't even get it to run properly).

What would be good ways to solve this problem? Maybe it is possible to launch a helper application which in turn starts a proper process, but that seems quite dirty.

Edit: PsExec was really clunky when I tried it and slow as hell (not sure why). Looking further at PsExec it seems it installs a temporary service on the remote machine to launch the application. Would this be the only way to spawn an interactive process using a proper identity? Should I include a helper service in the setup for the nodes? But even then, how would I communicate with it then?

like image 334
gix Avatar asked Apr 02 '09 20:04

gix


People also ask

How can I see what processes are running remotely windows?

tasklistBy running the command “tasklist /s hostname” where “hostname” is the remote computer you want to query, it will return a list of processes on the remote machine and some basic details about each process (PID, session number, memory usage, etc.).


4 Answers

PsExec is part of the sysinternals suite that can do that

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

If your servers are running windows 2008 you can also use

Terminal Services Remote App

like image 82
Ryu Avatar answered Sep 29 '22 20:09

Ryu


You can use the "at" command.

Open a command-line and type

at /?

Into the terminal. The one downside is that the time on the remote system needs to be within some reasonable delta of yours. It's also not instant. You have to wait a few seconds to make sure the remote scheduler doesn't miss the event entirely.

There is a WMI equivalent to this, and has the same basic caveats as at:

LISTING 3: Code to Create an Interactive Process on Windows Server 2003, Windows XP, and Win2K SP3 Machines

Const INTERVAL = "n"
Const MINUTES  = 1

strComputer = "compaq575"
strCommand  = "calc.exe"

Set objWMIService = _
    GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objScheduledJob = objWMIService.Get("Win32_ScheduledJob")

Set objSWbemDateTime = _
    CreateObject("WbemScripting.SWbemDateTime")
objSWbemDateTime.SetVarDate(DateAdd(INTERVAL, _
    MINUTES, Now()))

intReturnValue = objScheduledJob.Create(strCommand, _
    objSWbemDateTime.Value, False, 0, 0, True, intJobID)
WScript.Echo "Job ID: " & intJobID

I think most of the other ways to do it (without installing your own service) have been turned off by various service packs because of vulnerabilities.

like image 31
Christopher Avatar answered Sep 29 '22 21:09

Christopher


The following two post use .NET to execute remote processes.

  1. Using WMI

    http://weblogs.asp.net/steveschofield/archive/2006/06/06/WMI---start-a-process-on-remote-machine-passing-credentials_2E00_.aspx

  2. Codeproject Example

http://www.codeproject.com/KB/IP/RemotingExec.aspx

The examples execute with custom credentials & the remote executable is a Win Form app. Hope this helps.

like image 28
Ganesh R. Avatar answered Sep 29 '22 20:09

Ganesh R.


If the enire group is reasonably under your control, it may be possible to implement these remote processes as Windows Services. A service can be interactive (not by default though) and it can be remotely controlled via the standard Service Control Manager running on each Windows PC.

like image 34
MSalters Avatar answered Sep 29 '22 19:09

MSalters