C# 打开 rasphone.exe 带参数

C# open rasphone.exe with arguments

你能找到我的问题吗? 我无法使用正确的参数打开 rasphone.exe。

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    System.Diagnostics.ProcessStartInfo proc = new System.Diagnostics.ProcessStartInfo();
    proc.FileName = @"C:\windows\system32\cmd.exe";
    proc.Arguments = @"C:\Windows\System32\rasphone.exe -d ""My VPN""";
    System.Diagnostics.Process.Start(proc);
}

我也试过:

Process.Start(@"C:\Windows\System32\rasphone.exe", @" -d ""My VPN"" ");

或:

System.Diagnostics.Process.Start(@"C:\Users\***\Documents\VPN Launcher\VPN Launcher\VPN Launcher\startVPN.bat");

.bat 文件中:

start "" "C:\Windows\System32\rasphone.exe" -d "My VPN"

它打开 cmd/.bat,但我没有使用正确的参数打开 rasphone.exe。

欢迎来到 Whosebug。正如 docs 所说,您需要使用 3 双引号转义双引号:) 我不知道为什么它是强制性的,但这应该有效:

Process.Start(@"C:\Windows\System32\rasphone.exe", "-d \"\"\"My VPN\"\"\"");