Start a Remote Process

  • Thread starter Thread starter Billy Bob
  • Start date Start date
B

Billy Bob

Hello

In C# how can i start a remote process such as someapp.exe on a remote PC?
I know the remote PC's name, but how do I start the app on that PC?

Thanks
..
 
Hi Billy,
In C# how can i start a remote process such as someapp.exe on a remote PC?

Well, I don't have C# code ready-made, but I think using WMI is the best bet
for starting processes on remote machines. I found some WMI scripts from
TechNet, this one is supposed to start "calc.exe" on a remote machine called
"atl-ws-01":

-----------------
strComputer = "atl-ws-01"
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
errReturn = objWMIService.Create _
("calc.exe", Null, Null, intProcessID)
-----------------

Maybe you could translate this into C# WMI code quite easily.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
(e-mail address removed)
http://www.saunalahti.fi/janij/
 
Hi

I tried that and it does start the process, but there is one problem with
it. I've downloaded this code from MSDN and it works
.....http://msdn2.microsoft.com/en-us/library/aa720497(VS.71).aspx but
wanting to start the Asyncremoteclient.exe on the remote machine, so I tried
that via the WMI script but for some reason, even though the app starts and
appears in taskman it never communicates with the server.exe unless I
manually go to the remote client pc and type in remoteasyncclient.exe
myself.

Do network apps not start via a remote process?
 
Billy Bob said:
Hi

I tried that and it does start the process, but there is one problem with it. I've
downloaded this code from MSDN and it works
....http://msdn2.microsoft.com/en-us/library/aa720497(VS.71).aspx but wanting to start the
Asyncremoteclient.exe on the remote machine, so I tried that via the WMI script but for
some reason, even though the app starts and appears in taskman it never communicates with
the server.exe unless I manually go to the remote client pc and type in
remoteasyncclient.exe myself.

Do network apps not start via a remote process?

What you are trying does not work in general on Windows. The remote process runs in a
restricted security context, it does not run in the context of an interactive logon account
(if any), it runs in the security context of the remote WMI service and by default it's
impersonating the initiator (the WMI client). What does it mean to the application that was
started? First, this application has no way to interact with the user, even when it's a
console application, the output will go to a non visible desktop and there is no way to read
from the keyboard. Second, the "environment" is the one inherited from the Service that
launched the program, that means that variables like the home directory and current working
directory are not what you might expect, the profile loaded is not a user profile but a
service profile, so applications who expect this profile to be loaded will fail miserably.
Or otherwise stated, what you are trying is a no no in Windows, all you can do is use Remote
Destop or Terminal Services to start a remote interactive session and launch your
application from the command windows.

Willy.
 

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

Back
Top