我在我的服务器上使用 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);
此外,作为 info.Arguments 的一部分,我是否必须在 vmtoolsd.exe 的路径前加上 IP 地址,然后是驱动器路径?
最佳答案
希望下面的代码对您有所帮助。
第一个 .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");
demo.exe 中的代码:
static void Main (string [] args)
{
Console.WriteLine(args[0]);
Console.WriteLine(args[1]);
}
关于c# - 如何将参数传递给exe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29728896/