启动程序与参数 [英] Launch Program with Parameters
本文介绍了启动程序与参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何编写使用命令行导航到用户的Program Files目录下的程序一个非常简单的程序,然后启动 .exe文件
带参数?例如:
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
"C:\etc\Program Files\ProgramFolder\Program.exe C:\etc\desktop\file.spp C\etc\desktop\file.txt"
这将启动一个程序具有一定的项目文件和 .TXT
随之文件。
This launches a program with a certain project file and a .txt
file along with it.
推荐答案
您可以使用 ProcessStartInfo.Arguments 财产指定的参数字符串为您的程序:
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);
这篇关于启动程序与参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文