spd*_*cbr 6 c# psexec process.start
我在我的服务器上使用psexec在另一台服务器上运行exe文件.如何将参数传递给其他exe?
我在我的服务器上运行的exe是psexec,而后者必须运行位于另一个系统上的名为vmtoolsd.exe的exe.如何将参数传递给vmtoolsd.exe?另外,我在哪里通过它?我会将它作为info.Arguments的一部分传递给我吗?我试过了,但它不起作用.
ProcessStartInfo info = new ProcessStartInfo(@"C:\Tools");
info.FileName = @"C:\Tools\psexec.exe";
info.Arguments = @"\\" + serverIP + @"C:\Program Files\VMware\VMwareTools\vmtoolsd.exe";
Process.Start(info);
Run Code Online (Sandbox Code Playgroud)
另外,作为info.Arguments的一部分,我必须在vmtoolsd.exe的路径前加上IP地址,然后是驱动器路径?
Mou*_*Mou 17
希望以下代码可能有所帮助.
第一个.exe的代码:
Process p= new Process();
p.StartInfo.FileName = "demo.exe";
p.StartInfo.Arguments = "param1 param2";
p.Start();
p.WaitForExit();
or
Process.Start("demo.exe", "param1 param2");
Run Code Online (Sandbox Code Playgroud)
demo.exe中的代码:
static void Main (string [] args)
{
Console.WriteLine(args[0]);
Console.WriteLine(args[1]);
}
Run Code Online (Sandbox Code Playgroud)