简体   繁体   中英

C# open rasphone.exe with arguments

Can you find my problem? I can't open rasphone.exe with the right arguments.

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);
}

I also tried:

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

Or:

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

In the .bat file:

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

It opens the cmd/.bat but i dont open the rasphone.exe with the right arguments.

Welcome to StackOverflow. As docs said, you need to escape double-quotas with 3 double-quotas:) I don't know why it is mandatory, but this should work:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM