启动EXE
Dim info As System.Diagnostics.ProcessStartInfo
info = New System.Diagnostics.ProcessStartInfo()
info.FileName = EXE_NAME
info.Arguments = arg1 & " " & arg2
info.WorkingDirectory = Application.StartupPath
Dim Proc As System.Diagnostics.Process
Try
Proc = System.Diagnostics.Process.Start(info)
Proc.WaitForExit()
If Proc.HasExited = False Then
Proc.Kill()
End If
Catch ex As System.ComponentModel.Win32Exception
Return
End Try
info = New System.Diagnostics.ProcessStartInfo()
info.FileName = EXE_NAME
info.Arguments = arg1 & " " & arg2
info.WorkingDirectory = Application.StartupPath
Dim Proc As System.Diagnostics.Process
Try
Proc = System.Diagnostics.Process.Start(info)
Proc.WaitForExit()
If Proc.HasExited = False Then
Proc.Kill()
End If
Catch ex As System.ComponentModel.Win32Exception
Return
End Try
接收参数
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CmdArgs() As String = System.Environment.GetCommandLineArgs()
If CmdArgs.Length > 1 Then
arg1= CmdArgs(1).ToString
arg2 = CmdArgs(2).ToString
End If
End Sub
Dim CmdArgs() As String = System.Environment.GetCommandLineArgs()
If CmdArgs.Length > 1 Then
arg1= CmdArgs(1).ToString
arg2 = CmdArgs(2).ToString
End If
End Sub