C# open rasphone.exe with arguments

931 views Asked by At

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.

1

There are 1 answers

1
vasily.sib On BEST ANSWER

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\"\"\"");