Page 1 of 1

wait for vpn connection to finish in batch file?

Posted: Mon Oct 27, 2014 9:03 pm
by sdevries.otn
I am trying to write a bat file to:
1) Connect to VPN
2) Open RDP
3) Close VPN after RDP is closed.

So far:
start /wait vpncmd localhost /client /cmd AccountConnect <VPN Connection Here>

start /wait mstsc.exe <rdp file name>

start /wait vpncmd localhost /client AccountDisconnect <VPN Connection Here>

Notes:
Unfortunately, this seems to fire the RDP immediately. I'd lke to have it wait until after the IP Address window closes. I can manually time a break, but that does not really gaurantee a connection is established. Is there another vpncmd I can run using start /wait that will wait until an ip is established?

Re: wait for vpn connection to finish in batch file?

Posted: Thu Nov 06, 2014 7:36 am
by thisjun
Vpncmd doesn't have such command.

However, batch can know IP address status by errorlevel.
netsh interface ip show addresses "adapter name" | find "IP address"