vb.net 如何从 Vb 程序运行 exe 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25525509/
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
How to run an exe file from a Vb program
提问by Mohammad Reza Biglari
I use this code in VB to run an .EXE file that requires an input file and results in creation of an output file.
我在 VB 中使用此代码运行需要输入文件并导致创建输出文件的 .EXE 文件。
Process.Start("C:\glob.exe","C:\g.inp" )
It seems that the exe runs successfully but the output file don't get created.
似乎 exe 成功运行,但未创建输出文件。
Notewhen I run the exe file from cmd it makes the output files at the end so there's nothing wrong with the exe file.
请注意,当我从 cmd 运行 exe 文件时,它会在最后生成输出文件,因此 exe 文件没有任何问题。
回答by Pradeep Kumar
Use the System.Diagnostics.Processwith ProcessStartInfoto specify various parameters to launch your executable.
The Processclass gives you more control on the launched program than the Shellfunction.
使用System.Diagnostics.ProcesswithProcessStartInfo指定各种参数以启动您的可执行文件。该Process班为您提供了比已启动程序更多的控制Shell功能。
e.g.
例如
Dim psi As New ProcessStartInfo
psi.FileName = "C:\glob.exe"
psi.Arguments = "C:\g.inp"
psi.Verb = "runas"
Process.Start(psi)
回答by user2085339
you can use shell function in vb.net Shell("C:\procexp.exe", AppWinStyle.NormalFocus)
您可以在 vb.net Shell("C:\procexp.exe", AppWinStyle.NormalFocus) 中使用 shell 函数

