如何在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