简体   繁体   中英

Run multiple net use commands for a process using c#

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new 
                                System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C net use W: \\\\abcdpc25\\views\\Projects ";
process.StartInfo = startInfo;
process.Start();

I want to run multiple net use commands and i am not sure how to go about it

I am not sure if something like below would work .

startInfo.Arguments = "/C net use W: \\\\abcdpc25\\views\\Projects 
                      net use H: \\\\abcdpc25\\views\\Project456 net use E: 
                      \\\\abcdpc25\\views\\Project123";

Use & as the separator between commands and it should work.

You can also put all the net use statements in a batch file and put the batch file name on your command line.

You can also launch multiple processes, one for each net use.

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