OpenVPN Map Drives At Login

Every so often I have clients requesting that OpenVPN GUI automatically map networked drives once connected to their OpenVPN Server.  Fortunately OpenVPN GUI has built in support for running batch scripts once Connected or Disconnected. Note this tutorial is for the Windows based OpenVPN GUI client only. So without further ado, here we go. The process is rather simple, all that is needed are two batch files named the same as the .ovpn file with either _Up or _Down appended to the end. Below you will see the files highlighted in yellow. openvpn-gui-batch

It is important to note that these files must be in the same directory as your .ovpn configuration file. The contents of the files can be seen below. It seems fairly obvious, but note the Home_Up.bat file will run after connected and the Home_Down.bat will run after disconnected.



Did you find this article useful? Why not share it with your friends?

2 thoughts on “OpenVPN Map Drives At Login

  1. Might as well have ‘Home_Down.bat’ cleanup everything. Leaving those labels behind is a bit sloppy.

    @echo off

    REM Remove Mapped drives
    net use W: /delete
    net use X: /delete

    REM Cleanup added registry entries
    reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\## /f
    reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\## /f


Leave a Reply

Your email address will not be published. Required fields are marked *