I have a mapped network share (through sshfs) that is only available when connected to my company's VPN, and whenever I'm not connected to the VPN Windows think that the credentials are wrong and keeps asking for the correct ones. The only way to make it stop popping up every few minutes is to disconnect from the drive, which unmaps it.

Is there a way to keep the drive mapped while the VPN is off without the constant credentials requests?

*I'm using Win 10


The way I do this is to put two batch files on my desktop: One file to connect the drives and one file to delete the drives. I have done this for a long time and it works very well.


This is what i run on my personal laptops for this reason.

Create an event log with the trigger set as "On event - Log:Application, Source: RasClient, Event ID:20225" which executes the batch file below.

Create a batch file that queries AD for the users logon script then executes the user's logon script. (Below)

ECHO off


 /f "delims=" %%A in ('net user /domain %username% ^| find /i "logon script"') do set "var=%%A"

    SET subvar=%var:~29%

    SET script=\\domain.com\NETLOGON\%subvar%

    START /B %script%


Event ID 20225 is the event logged for a successful VPN connection.

This method allows for an environment with multiple logon scripts and everything needed here can be deployed through Group Policy.

Hope this helps...

  • I can't seem to find any event logs from the VPN client I'm using (forticlient). Is there another way to detect a connection/disconnection? – Matan Ben Moshe Oct 25 at 13:24
  • Can you see anything under Event Viewer > Windows > Application? – iEoj Oct 26 at 2:10
  • Not from the VPN application or anything else that happens at the time or around the time of connection. In security there is a 'logon' event at that time but it's not unique to it so I can't use it for this purpose. – Matan Ben Moshe Oct 27 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.