批量启动带参数错误

Batch start with parameters Error

我试图只制作一个小程序,其中包括从 .java 文件反编译和启动这两个步骤。我无法 运行 正确地 .bat 文件,因为 DOS 不接受我想要的空格。

这是我的代码:

Process.Start("cmd.exe", "/c start "" """ & TextBoxJavacPath.Text & _
"""" & " " & """" & TextBoxFile.Text & """")

就是这样出来的字符串:(没错)

/c "C:\Program Files\Java\jdk1.8.0_60\bin\javac.exe"
"C:\Users\Niklas\Desktop\Java\Kap06\src\eingabe\LetsReadLine.java"

如果我通过在控制台输入它,它可以工作,但是通过 vb.net 它不起作用。

错误如下:The command "C:/Program" is written incorrect or couldn't be found.

尝试使用此代码(我不知道它是否有效):

Private Sub Start(javacPath As String, file As String)
    Using p As New Process With {
        .StartInfo = New ProcessStartInfo With {
            .WorkingDirectory = Path.GetDirectoryName(javacPath),
            .Arguments = "/c """ & Path.GetFileName(javacPath) & """ """ & file,
            .FileName = "cmd",
            .CreateNoWindow = True}}
        p.Start()
    End Using
End Sub

然后像这样调用方法:

Start(TextBoxJavacPath.Text, TextBoxFile.Text)

我无法测试代码,因为我没有任何 .java 文件...