Launch Program with Parameters

2019-01-12 02:16发布

How do I write a very simple program that uses the command line to navigate to a program in the user's Program Files directory, then launches the .exe with a parameter? For example:

"C:\etc\Program Files\ProgramFolder\Program.exe C:\etc\desktop\file.spp C\etc\desktop\file.txt"

This launches a program with a certain project file and a .txt file along with it.

3条回答
一夜七次
2楼-- · 2019-01-12 03:00

Just create a new text file, name it "go.cmd" and put the following in there:

"C:\etc\Program Files\ProgramFolder\Program.exe C:\etc\desktop\file.spp C\etc\desktop\file.txt"

Voila, you have your program!

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-12 03:02

You can use the ProcessStartInfo.Arguments property to specify the string of arguments for your program:

ProcessStartInfo startInfo = new ProcessStartInfo();        
startInfo.FileName = @"C:\etc\Program Files\ProgramFolder\Program.exe";
startInfo.Arguments = @"C:\etc\desktop\file.spp C:\etc\desktop\file.txt";
Process.Start(startInfo);
查看更多
混吃等死
4楼-- · 2019-01-12 03:14

if you want to pass full executable path and parameters the program you need is the windows command prompt.

查看更多
登录 后发表回答