I want to be able to connect to a network via command line in Windows. My goal is to script out remoting into my work computer. I hate having to always manually connect to the VPN connection and then rdping into my work machine. I want to just have a script which will do both of it for me. I know how to rdp via command line, I just need to know how to connect to my VPN via command line.
3 Answers
Have you looked at the netsh
command which can be used to control the network in many ways?
If you are using a microsoft VPN, the built-in command you are looking for is "rasdial". As far as I can tell, netsh won't help.
After you've set up your VPN connection, use
rasdial <VPNName> <username> *
to request a password and initiate the connection. Unfortunately, I don't know a way to use the password saved via the GUI. Then use
rasdial <VPNName> /DISCONNECT
to end the connection. For other options, of course use rasdial /?
If you aren't using the built-in Microsoft VPN drivers, then you will need to use a command line utility specific to your VPN vendor.
If you want to connect a wireless network before you have connected, and network profile is saved, you can run:
netsh wlan connect ssid="WIFI_SSID" name="PROFILE_NAME" interface="NETWORK INTERFACE"