spdcbr spdcbr - 1 year ago 61
C# Question

How to pass parameters to an exe?

I am using psexec on my server to run an exe file on another server. How do I pass parameters to the other exe ?

The exe that I am running on my server is psexec which in turn must run the exe named vmtoolsd.exe located on another system. How do I pass parameters to vmtoolsd.exe ? Also, where do I pass it ? Would I pass it as part of the info.Arguments ? I've tried that but it isn't working.

ProcessStartInfo info = new ProcessStartInfo(@"C:\Tools");
info.FileName = @"C:\Tools\psexec.exe";
info.Arguments = @"\\" + serverIP + @"C:\Program Files\VMware\VMwareTools\vmtoolsd.exe";

Also, as part of info.Arguments would I have to preface the path of vmtoolsd.exe with the IP address, followed by the drive path ?

Mou Mou
Answer Source

Hope the below code may help.

Code from first .exe:

Process p= new Process();
p.StartInfo.FileName = "demo.exe";
p.StartInfo.Arguments = "param1 param2";


Process.Start("demo.exe", "param1 param2");

Code in demo.exe:

static void Main (string [] args)

Mark as answer if help my answer

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download