开发者

Launch Program with Parameters

开发者 https://www.devze.com 2023-02-14 14:07 出处:网络
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:

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:\e开发者_JS百科tc\desktop\file.spp C\etc\desktop\file.txt"

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


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);


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!


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

0

精彩评论

暂无评论...
验证码 换一张
取 消