Avoid VPN connection interfering with LogOn script

0

I'm having a problem with my VPN connection at work, interfering with some Internet Connectivity during start up.

I have set up the VPN to not "Use default gateway on remote network" so, once I connect to the VPN, my Internet traffic goes through the normal route and everything works like a charm, including mapped network drives and so on.

The problem I have is at start up (basically when I come in in the morning), what happens here is that there is a Log On script that maps my Documents folder to a network drive (H: as usual). If I left the VPN from the day before, the mapping is broken and I cannot browse to the H drive. The solution is generally to disconnect the VPN, browse to the H drive (which will work ok now) and then reconnect the VPN (at this point the H drive will keep on working fine).

Does anyone have any idea what may cause this and how to overcome the problem? I'm sorry I don't have access to the Log On script but I'm assuming is a pretty standard thing (I've seen it in other workplaces).

I'm an admin on the machine and I was thinking that a solution could be to add a script that disconnect the VPN (using rasdial) before Log On. Do you think it's a good idea or is there something else I should consider?

Tallmaris

Posted 2014-08-20T10:50:42.520

Reputation: 101

Since you're an admin on the machine, it wouldn't hurt to check "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup" to see if the login script runs from there. It's common to see scripts there to map drives http://superuser.com/questions/557472/on-login-how-do-i-get-windows-to-mount-connect-a-mapped-network-drive-automatic

– root – 2014-08-20T11:34:26.813

Hi @root. Nope, the script is \\%logonserver%\netlogon\userscript.bat but when I browse the netlogon folder it's empty... – Tallmaris – 2014-08-20T13:45:00.283

Answers

0

You could use the following, which will automate the process you posted as a work-around:

@echo off
rem disconnect from VPN
rasdial vpnserver /disconnect

rem explore to the H drive
cd H:
explorer .

rem reconnect to VPN
rasdial vpnserver stationname password

You may also consider removing the map to H and recreating it, possibly after disconnecting from the VPN and before exploring to H:

rem remove map to H
net use H: /del /y

rem restore map to H
net use H: "\\network\path"

root

Posted 2014-08-20T10:50:42.520

Reputation: 2 992

Is there a way to run this before LogOn? In the Task Scheduler it's not very clear what is executed before what... – Tallmaris – 2014-08-20T16:01:20.580

I'll see what happens tomorrow morning... I'll skip the reconnect part since I don't like to have my password sitting in clear there... – Tallmaris – 2014-08-20T16:08:01.503

Others have used srvany to run scripts as a service http://superuser.com/questions/548192/how-can-i-start-a-batch-script-before-logging-in . Although in a work environment, it's always best to just speak with your admin

– root – 2014-08-20T16:08:15.643