I have a down script (script with the same name as my OVPN file + "_down.bat") in the config folder. It looks as follows:
Code: Select all
@echo off
REM if domain joined, will get drive mapping from GPO, but if not, should map and unmap on connect/disconnect
if /I not "%USERDOMAIN%" == "mydomain" (
if exist K:\ (
net use K: /DELETE
)
)
Code: Select all
@echo off
REM if domain joined, will get from GPO
if /I not "%USERDOMAIN%" == "mydomain" (
REM If drive exists already, skip
if not exist K:\ (
REM Map away (credentials need to be in credential manager. Start | Credential Manager | Windows Credentials)
net use K: \\servername\sharename
)
)
When I shutdown I often get errors that the batch script can't run. Likely this is because Windows won't let OpenVPN launch a new program while it's in the process of shutting down. Is there a way to make OpenVPN avoid running the script if the down of the VPN tunnel is because of a shutdown, or if the machine is in the process of shutting down? It's not the end of the world to click 'OK' to the message on shutdown, but still would be nicer if it handled it gracefully.
Thoughts?