使用参数启动程序 [英] Launch Program with Parameters

查看:20
本文介绍了使用参数启动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写一个非常简单的程序,使用命令行导航到用户程序文件目录中的程序,然后使用参数启动 .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:etcProgram FilesProgramFolderProgram.exe C:etcdesktopfile.spp Cetcdesktopfile.txt"

"C:etcProgram FilesProgramFolderProgram.exe C:etcdesktopfile.spp Cetcdesktopfile.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:etcProgram FilesProgramFolderProgram.exe";
startInfo.Arguments = @"C:etcdesktopfile.spp C:etcdesktopfile.txt";
Process.Start(startInfo);

这篇关于使用参数启动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆