Skip to content

Instantly share code, notes, and snippets.

@arjankuijpers
Forked from adrienne/NerderyVPN.bat
Created July 30, 2016 16:48
Show Gist options
  • Save arjankuijpers/b1406118ee5c48f5ebdcbd31fb72f354 to your computer and use it in GitHub Desktop.
Save arjankuijpers/b1406118ee5c48f5ebdcbd31fb72f354 to your computer and use it in GitHub Desktop.
A batch file to connect to the VPN and mount the network storage as a drive
@echo off
if exist n:\home goto DISCONNECTME else goto CONNECTME
:CONNECTME
REM NOTE: in all of the below variables EXCEPT for mydrivename , double-quote the values!
REM This is the name of the VPN you've got set up
set myvpnname="Name of your VPN connection"
REM Your LDAP username and password
set myusername="username"
set mypassword="password"
REM The name of your CIFS instance, to use for mapping the drive
REM -- DO NOT QUOTE THIS VALUE!
set mydrivename=cifs##.bravo
rasdial %myvpnname% %myusername% %mypassword%
timeout 4
net use n: "\\%mydrivename%\public" %mypassword% /user:%myusername% /persistent:no
goto DONE
:DISCONNECTME
net use n: /delete
timeout 2
rasdial %myvpnname% /d
goto DONE
:DONE
@echo on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment