【Winform】带参启动外部EXE

启动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

接收参数
    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

原文地址:https://www.cnblogs.com/sekihin/p/1132136.html
Creative Commons License 本作品采用 知识共享署名-非商业性使用 2.5 中国大陆许可协议进行许可。