[vpn-help] Domain login and network drives map (example script inside)

Gerd Röthig gerd.roethig at gmail.com
Mon Oct 21 08:53:52 CDT 2013


Hello,

 

please see below an example script that I use successfully for quite some
time now:

 

@echo off

set ccmd="%ProgramFiles%\ShrewSoft\VPN Client\ipsecc.exe"

set cfg="test.vpn"

set DRVFILE=drives.txt

 

rem *****************************************

rem * start VPN services                    *

rem *****************************************

 

start /w surun Start_VPN_Services.cmd

 

start "VPN" %ccmd% -r %cfg% -u myusername

 

:WAIT1

sleep 2

Rem ping a server that is only reachable when VPN is established

ping -n 2 testserver.vpndomain >nul 2>&1

@if errorlevel 1 goto WAIT1

 

echo Wait for VPN connection to be set up (6s)

sleep 6

 

rem *****************************************

rem * map network drives                    *

rem *****************************************

 

call netstart.cmd

 

exit

 

And here are the other scripts:

Start_VPN_Services.cmd

 

@echo off

rem *****************************************

rem * Start VPN services                    *

rem *****************************************

echo.

echo Starting VPN services...

net start "ShrewSoft IKE Daemon"

net start "ShrewSoft IPSEC Daemon"

 

netstart.cmd:

 

@echo off

rem *****************************************

rem * map network drives                    *

rem *****************************************

 

set DOMAIN=.mydomain.com

set NETUSER=DOMAIN\Username

set PASSWD=mypassword

 

set L=

set P=/persistent:no

 

set DRVFILE=drives.txt

 

REM Set correct login if the computer is logged in as a different user

 

if %USERDOMAIN%\%USERNAME% NEQ %NETUSER% (

echo logging in as pre-defined user...

set L=/user:%NETUSER% %PASSWD%

)

 

for /f "tokens=2,3 delims= " %%i in (%DRVFILE%) do (

 

if not exist %%i (

echo Drive %%i is mapped...

net use %%i %%j %L% %P%

)

)

 

rem --- Synchronising client PC system clock

surun net time \\testserver.mydomain /YES /SET

 

finally, the drives.txt file needed by the netstart script:

 

OK           H:        \\FS01.mydomain.com\user$ 

OK           I:        \\FS02.mydomain.com\Prog3 

OK           T:        \\FS02.mydomain.com\Data1

 

All these scripts and the drives config file should be placed into one
directory, and, of course, adjusted to your requirements. SuRun is a neat
little program which allows several commands to be run as an administrator.
See http://kay-bruns.de/wp/software/surun/ for more details.

 

In order to avoid the disconnect problem described here in the mailing list
I start the Shrew Soft VPN services only if required. After closing the VPN
connection, I also shutdown these services.

 

Kind regards,

 

Gerd

From: vpn-help-bounces at lists.shrew.net
[mailto:vpn-help-bounces at lists.shrew.net] On Behalf Of Rosaida Angulo
Sent: Friday, October 18, 2013 9:41 PM
To: vpn-help at lists.shrew.net
Subject: [vpn-help] Domain login and network drives map

 

Hi,

 

I downloaded the Professional version and I tried to get my network drives
mapped through the VPN as we do in our office.

 

The tunnel was established, I was asked to enter my domain credentials, I
accessed the server folders and files but it doesn’t map automatically the
drives that we have configured in our Windows server 2008 R2 through GPO.

 

Is there a way to have my network drives mapped with my connection with
Shrew Soft VPN?

 

Thanks,

Rosie

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.shrew.net/pipermail/vpn-help/attachments/20131021/231db09a/attachment.html>


More information about the vpn-help mailing list