-1

这是我在这里的第一个问题,因为我最终陷入了死胡同。我正在使用 ZIP 2 Secure EXE(来自 Chilkat 的非常好的软件)为应用程序创建 setup.exe。ZIP 2 Secure EXE 可以在没有带有一个或多个参数的 GUI 的情况下运行。
问题是,当我调用 ZIP 2 Secure EXE (ChilkatZipSE.exe) 而不使用 OpenFileDialog 表单来确定 ChilkatZipSE.exe 的位置时,它不会使用 System.Diagnostics.Process 类运行进程。我调用 ChilkatZipSE.exe 的方式是“..\ChilkatZipSE.exe -cfg settings.xml”。settings.xml 一切正常,并且有创建 setup.exe 文件所需的 UnlockCode 节点。当我使用 OpenFileDialog ChilkatZipSE.exe 创建所需的 setup.exe 并且它工作正常。
贝娄是我使用的代码:

Private Sub btnStartApp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartApp.Click

    If txtExtAppPath.Text.Length > 0 AndAlso System.IO.File.Exists(txtExtAppPath.Text) Then

        Dim myFile As New FileInfo(txtExtAppPath.Text)
        txtExtAppLog.Text = StartApplication(myFile.FullName, txtExtParams.Text, chkIsHidden.Checked)
        'txtExtAppLog.Text = StartApplication(txtExtAppPath.Text, txtExtParams.Text, chkIsHidden.Checked)

    End If

End Sub

Public Function StartApplication(ByVal fileFullPath_ As String, ByVal fileParameter_ As String, ByVal isHidden_ As Boolean) As String

    Dim lassie As String = String.Empty

    Try

        Dim newProcess As New ProcessStartInfo()
        newProcess.FileName = fileFullPath_
        newProcess.Arguments = fileParameter_
        If isHidden_ Then newProcess.WindowStyle = ProcessWindowStyle.Hidden

        If System.IO.File.Exists(fileFullPath_) Then

            Using startedNewProcess As Process = Process.Start(newProcess)
                'startedNewProcess.EnableRaisingEvents = True
                startedNewProcess.WaitForExit()
            End Using

        Else

            lassie = "File " + fileFullPath_ + " doesn't exist."

        End If

    Catch ex As Exception

        lassie = ex.Message

    End Try

    Return lassie

End Function

谢谢,万能。

4

1 回答 1

0

问题是给定的参数。使用 OpenFileDialog 时,它知道 settings.xml 的位置。但是在没有 OpenFileDialog 的情况下调用“..\ChilkatZipSE.exe -cfg settings.xml”时,它必须用作“..\ChilkatZipSE.exe -cfg ..\settings.xml”

于 2017-06-17T22:26:30.267 回答