Skip to content

Instantly share code, notes, and snippets.

@aaronsnoswell
Last active March 2, 2018 04:04
Show Gist options
  • Save aaronsnoswell/1e0fa653c64bf4caabbe103e814e963e to your computer and use it in GitHub Desktop.
Save aaronsnoswell/1e0fa653c64bf4caabbe103e814e963e to your computer and use it in GitHub Desktop.
Toggles a VPN, then does some other things (e.g. mount / unmount network drives)
@echo off
:: Toggles a VPN connection and does some other things
:: [e.g. connect/disconnect shared drives]
:: To set up a new VPN: type "rasphone /a" in the Run dialog [Win+R]
set vpn_name="EAIT VPN Connection"
ipconfig | find /i %vpn_name% && (
:: Disconnect VPN
net use G: /delete
net use H: /delete
net use S: /delete
net use W: /delete
rasphone -h %vpn_name%
) || (
:: Connect VPN
rasphone -d %vpn_name% && (
net use H: \\smoke.eait.uq.edu.au\uqasnosw
net use S: \\smoke.eait.uq.edu.au\software
net use W: \\smoke.eait.uq.edu.au\web
net use G: \\smoke.eait.uq.edu.au\groups && (
:: If G drive is successfully mounted, run a backup
echo "Backing up PhD files..."
"C:\Program Files\FreeFileSync\FreeFileSync.exe" "E:\ITEE G drive SyncSettings.ffs_batch"
if errorlevel 1 (
echo "Errors occurred during backup. Please see C:\Users\uqasnosw\AppData\Roaming\FreeFileSync\LastSyncs.log"
pause
) else (
echo "Backup succeeded"
)
) || (
echo "G drive not mounted - backup will not run"
pause
)
)
)
@aaronsnoswell
Copy link
Author

You can add this to your windows 10 taskbar, but it's a pain.

  1. Rename it to ".exe"
  2. Drag it to the taskbar to create a shortcut
  3. Rename it to ".bat"
  4. Right-click the shortcut in the taskbar and fix the reference so it points to the .bat file
  5. You can give it a pretty icon: I suggest something from The Noun Project, white on transparent (you'll need to open it in GIMP or something else and convert to .ico)
  6. Profit...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment