わかりました、これは名前付き VPN を検出するためのハックなソリューションです。何らかの理由で VPN に接続できない場合 (ネットワーク接続がダウンしている、VPN が存在しないなど)、エラーがスローされます。
テストする特定のエラー コードは次のとおりです。
リモート アクセス エラー 800 - VPN 接続を確立できません。
VPN サーバーに到達できないか、セキュリティ パラメータがこの接続に対して適切に構成されていない可能性があります。
リモート アクセス エラー 623 - システムは、この接続の電話帳エントリを見つけることができませんでした。
提起された私の質問に実際には答えません(ただし、実際の問題には十分に機能します)。
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.FileName = "rasdial.exe"
p.StartInfo.Arguments = """Company HQ"""
p.Start()
If Not p.WaitForExit(My.Settings.VpnTimeout) Then
Throw New Exception( _
String.Format("Connecting to ""{0}"" VPN failed after {1}ms", sVpn, My.Settings.VpnTimeout))
End If
If p.ExitCode <> 0 Then
Throw New Exception( _
String.Format("Failed connecting to ""{0}"" with exit code {1}. Errors {2}", sVpn, p.ExitCode, p.StandardOutput.ReadToEnd.Replace(vbCrLf, "")))
End If