Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Remote Process?

Status
Not open for further replies.

tEkHEd

IS-IT--Management
Jan 29, 2003
261
GB
Can anyone please give me some pointers on how to invoke a process (such as MSIEXEC) on a remote machine with commandline args?

I am fairly familiar with the Process Class, and can invoke processes locally.. I just need to be able to do this remotely.

Thanks in adv for any help..
 
I can't really help you with the answer you want (and I will be watching to see if anyone else has a better idea), but I don't know any direct way to do this in .Net

What I have done in the past (where I need to run remote processes) is use one of 3 different tools.. If you have MSDE or SQL Server installed on the target systme, you will find that using the OSQL tool to execute processes via xp_cmdshell. At times I have used the AT command (of course the scheduler service needs to be running for that.) and last but not least I have used the PsExecute command from sysinternals


The last is probably the coolest. It goes deep down to create a remote process via the ipc$ connection. PStools come with 3 tools psexecute, pslist and pskill. Kill stops processes, list shows all running processes and execute....

HTH


Rob
 
Well I could use psexec, I am used to that with VBScript.. but the way that I want to invoke is with accessing the Win32_Process class in WMI with the ManagementObjectSearcher class in .NET

I can manage to invoke a process with the InvokeMethod("Create") syntax, but I am unable to correctly invoke an instance of MSIEXEC to install apps.

I don't have the code with me right now, but when I am back at work I will post up and maybe you/another tek-tipper can help out.

thanks :)
 
I can invoke the process with this code, however I am unable to invoke this in an interactive mode.

Code:
Dim cOptions As New ConnectionOptions()
Dim workingDir As String = "C:\Temp"
Dim mCommand As String = "notepad"
Dim servername As String = "remoteserver"
Dim scope As New ManagementScope("\\" & servername & "\root\cimv2", coptions)
Try
    scope.Connect()
    Dim mp As New ManagementPath("Win32_Process")
    Dim mo As New ManagementClass(scope, mp, New ObjectGetOptions(Nothing, New TimeSpan(0, 0, 0, 5), True))
    Dim inParams As ManagementBaseObject = mo.GetMethodParameters("Create")
    Dim options As New InvokeMethodOptions()
    inParams("CommandLine") = mcommand
    inParams("CurrentDirectory") = workingdir
    Dim mbo As ManagementBaseObject = mo.InvokeMethod("Create", inParams, options)
    Dim rv As Object = mbo("returnvalue")
    Dim prid As Object = mbo("processid")
Catch e As Exception
    Console.WriteLine("Failed to connect: " + e.Message)
End Try

I want to invoke an instance of MSIEXEC to install software, however I need this to be interactive to complete.

any help is appreciated...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top