如何在Visual Basic 2010中打开一个程序? (就像从运行“Application.txt”“C:\” Visual Basic项目中如何在Visual Basic 2010中打开一个程序?
Public Class getfrom
Dim getfrom As String
Dim saveto As String
Dim download As Boolean
Function openRunt()
Dim myProcess As New Process()
Try
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.FileName = "C:\\Runt.exe"
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
Catch e As Exception
' do nothing.
End Try
Return False
End Function
Function setVariables()
' Download the file from..
getfrom = "http://sourceforge.net/projects/iforsm/files/iForsm.exe"
' Download the file to..
saveto = "C:\Runt.exe"
' Allow download..
download = True
Return False
End Function
Private Sub getfrom_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
setVariables()
If download = True Then
My.Computer.Network.DownloadFile(getfrom, saveto)
Dim fileExists As Boolean
fileExists = My.Computer.FileSystem.FileExists("C:\Runt.exe")
If fileExists = True Then
'System.Diagnostics.Process.Start("notepad.exe", "c:\Application.txt")
openRunt()
End If
Else
End
End If
'End
End Sub
End Class
我已经试过 “的Process.Start(” C:\ Runt.exe “)” 和你的榜样。他们都没有说这个参数是不正确的。 – 2010-08-06 17:05:39
@Anonymous the Great你能编辑你的问题并发布你正在使用的代码吗?如果你试图启动的进程无法找到,你通常会得到一个异常,否则你开始的进程可能需要参数而没有被传递。 – 2010-08-06 17:30:16
已发布。 :) 谢谢。 – 2010-08-06 21:52:29