简体   繁体   中英

Defining folder and parameters in process.start?

I'm trying to create a simple launcher for anti-virus programs using c#, and having a bit of difficulty understanding what im missing.

i want to run cmd.exe, then run sav32cli.exe with the argument "e:" so it always scans drive E. this is located in "C:\Program Files (x86)\Sophos\Sophos Anti-Virus"

this is the line I have, but when I run it the program closes.

System.Diagnostics.Process.Start("cmd", "cd "c:/Program Files (x86)/Sophos/Sophos Anti-Virus/" && sav32cli.exe e: ");

or is there a better suited process for this?

You don't need to use cd to direct to the folder. Just use absolute path to access the exe.

Process p = new Process();
// the full path of exe
p.StartInfo.FileName = @"D:/Program Files (x86)/Sophos/Sophos Anti-Virus/sav32cli.exe";
// set the argument
p.StartInfo.Arguments = "e:";
p.Start();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM