Private wrk_sh As Shell
'For all connections found...
For wrk_ptr = 0 To Gen_load_balancing_connections.Size - 1
'Set up shell to set adapter metric of connection to 5
wrk_args.Clear
wrk_args.Add("/c")
wrk_args.Add("powershell.exe set-netroute -interfacealias '" & Gen_load_balancing_connections.Get(wrk_ptr) & "' -routemetric 5")
wrk_sh.InitializeDoNotHandleQuotes("Event_shell2", "cmd.exe", wrk_args)
Try
'Run shell with a 10 min timeout
wrk_sh.Run(600000)
'Wait for shell to terminate...
Wait For Event_shell2_ProcessCompleted(Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
If Success And ExitCode = 0 Then
Else
wrk_sms = wrk_sms & CRLF & Gen_load_balancing_connections.Get(wrk_ptr) & " - error setting adapter metric"
wrk_log = wrk_log & Gen_crlf & "Error after shell wait (setting adapter metric)..."
wrk_log = wrk_log & Gen_crlf & "Success: " & Success & Gen_crlf & "ExitCode: " & ExitCode & Gen_crlf & "StdOut: " & StdOut & Gen_crlf & "StdErr: " & StdErr
End If
Catch
wrk_sms = wrk_sms & CRLF & Gen_load_balancing_connections.Get(wrk_ptr) & " - error setting adapter metric"
wrk_log = wrk_log & Gen_crlf & "Error at shell run (setting adapter metric)..."
End Try
Next