Killing or launching a process remotely
-
So I am able to successfully enumerate the processes on a machine using the remote machine's name on the network such as: Process[] myProcesses = Process.GetProcesses("Machine_Name_Here"); However, I'd like to also use myProcesses[0].Kill() for example to kill the process and then after use something like Process.Start("blah") to start it again. The problem I am running into is that Process.Kill is not supported on remote machines. Additionally, I am not sure if I am able to launch the process through Process.Start either. Is there anything I can do for this desired functionality?
-
So I am able to successfully enumerate the processes on a machine using the remote machine's name on the network such as: Process[] myProcesses = Process.GetProcesses("Machine_Name_Here"); However, I'd like to also use myProcesses[0].Kill() for example to kill the process and then after use something like Process.Start("blah") to start it again. The problem I am running into is that Process.Kill is not supported on remote machines. Additionally, I am not sure if I am able to launch the process through Process.Start either. Is there anything I can do for this desired functionality?
InvalidTypecast wrote:
The problem I am running into is that Process.Kill is not supported on remote machines. Additionally, I am not sure if I am able to launch the process through Process.Start either.
Neither is starting a remote process, for the obvious security implications. You can start a NON-INTERACTIVE process remotely using the WMI Win32_Process class. But, again, the user will NOT see any indication that the process is running. It will not be allowed to put up ANY user interface at all.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
InvalidTypecast wrote:
The problem I am running into is that Process.Kill is not supported on remote machines. Additionally, I am not sure if I am able to launch the process through Process.Start either.
Neither is starting a remote process, for the obvious security implications. You can start a NON-INTERACTIVE process remotely using the WMI Win32_Process class. But, again, the user will NOT see any indication that the process is running. It will not be allowed to put up ANY user interface at all.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Yes, these are just command line applications with no interactivity that I need to restart essentially. Do you know of an article that provides a noobie example on using WMI for this?
-
Yes, these are just command line applications with no interactivity that I need to restart essentially. Do you know of an article that provides a noobie example on using WMI for this?
Not specifically for the Win32_Process class, but if you Google "C# WMI invoke method", you'll get something like this[^]. You can find the docs on the Win32_Process class here[^]. You're looking for the Create and Terminate methods.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Yes, these are just command line applications with no interactivity that I need to restart essentially. Do you know of an article that provides a noobie example on using WMI for this?
Did you try searching for the keywords? (WMI, win32_process_ A quick search returned these results: Howto: (Almost) Everything In WMI via C# Part 2: Processes[^] Windows Management Instrumentation (WMI) Implementation[^]
#region signature my articles #endregion