【Winform】带参启动外部EXE

启动EXE文件与接收参数
本文介绍了一种使用Visual Basic .NET启动外部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()Sub frmMain_Load()Sub frmMain_Load()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

From:http://www.cnblogs.com/sekihin/archive/2008/04/01/1132136.html

转载于:https://www.cnblogs.com/yuanjw/archive/2008/04/22/1165013.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值