vb.net 使用“Shell”运行带参数的可执行文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17498754/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run an executable file with parameters using "Shell"
提问by Leonardo Joksan
My problem that mess with game ever laid direct in vb and yet will no longer tested and works in start.bat see the code:
我的游戏问题曾经直接放在 vb 中,但将不再测试并在 start.bat 中工作,请参阅代码:
@echo off
start main.exe gt550
exit
would like to know the following, how can I run this command in Shell? well tried and failed
想知道以下内容,如何在 Shell 中运行此命令?尝试过但失败了
Shell(CurDir() & "\" & "cabalmain.exe", "breaklee")
I just want to run a program. exe inside the shell over with a parameter.
我只想运行一个程序。shell里面的exe带一个参数过来。
回答by Karl Anderson
You should consider using Process.Startinstead of Shell, as Shellis a holdover from the VB 6 days and Process.Startis built into the .NET Framework.
您应该考虑使用Process.Start代替Shell,因为它Shell是 VB 6 天的保留版本,并且Process.Start内置于 .NET Framework 中。
Here is an example of running Microsoft Word via the command line, passing it parameters, including file name and any flags:
下面是通过命令行运行 Microsoft Word 的示例,向其传递参数,包括文件名和任何标志:
Sub Main()
OpenMicrosoftWord("C:\Users\Sam\Documents\Office\Gears.docx")
End Sub
''' <summary>
''' Open the path parameter with Microsoft Word.
''' </summary>
Private Sub OpenMicrosoftWord(ByVal f As String)
Dim startInfo As New ProcessStartInfo
startInfo.FileName = "WINWORD.EXE"
startInfo.Arguments = f
Process.Start(startInfo)
End Sub

