Running Login Script after establishing a VPN connection

Running Login Script after establishing a VPN connection

Post by VEpDb29wZX » Sun, 11 May 2008 02:42:00


I want to create a script the user can run that pulls his objuser.scriptpath
properties, and runs the login script specified.

Is there a way to simply restart the login process (the part that goes to
that location and runs the specified script)?

So far I have a script that get the correct field, but I dont know how to
run/launch a bat file using that information. Ive tried wscript.run and
wsshell.run, but they dont seem to work. Any suggestions?

Set oNet = Wscript.CreateObject("Wscript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & ADSysInfo.UserName &"")
Set WshShell = CreateObject("Scripting.FileSystemObject")

Wscript.echo "Script Path: \\domain.loc\netlogon\ou\"& objUser.ScriptPath
'wscript.run "\\domain.loc\netlogon\ou\"& objUser.ScriptPath
'wshshell.run "\\domain.loc\netlogon\ou\"& objUser.ScriptPath


Set oNet = Wscript.CreateObject("Wscript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & ADSysInfo.UserName &"")
Set WshShell = CreateObject("Scripting.FileSystemObject")
 
 
 

Running Login Script after establishing a VPN connection

Post by VEpDb29wZX » Sun, 11 May 2008 03:03:01

Well, I moved on and decided to map a network drive, run the bat file, then
disconnect the network drive.

Only one problem. The network drive disconnects before the bat file finishes
running.

What is the most gracefull way to fix this new issue (create a timer?)?

Set objNetwork = Wscript.CreateObject("Wscript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & ADSysInfo.UserName &"")
Set WshShell = WScript.CreateObject("WScript.Shell")
Wscript.echo "z:\"& objUser.ScriptPath

objNetwork.MapNetworkDrive "z:", "\\domainx.com\netlogon"
wshshell.run "z:\folder\login.bat"
objNetwork.RemoveNetworkDrive "z:"

---------------

 
 
 

Running Login Script after establishing a VPN connection

Post by MV » Sun, 11 May 2008 05:40:03

Put the "net use z: /d" into "login.bat".

You could simplify things considerably if you used UNC coding
for your logon script. In this case you would not need to map
or unmap a share to drive Z:.
 
 
 

Running Login Script after establishing a VPN connection

Post by VEpDb29wZX » Sun, 11 May 2008 06:04:00

We are using kixart in our login process. I cant really modify for the
login.bat file, because it would cause issues with people logging in normally.

I suppose I could call up the text file with the actuall mapped drives and
parse it for UNC paths. Put those UNC paths into an array and then map them.
 
 
 

Running Login Script after establishing a VPN connection

Post by MV » Sun, 11 May 2008 06:15:27

hat calls up your VB Script program? Do you have any
control over it? If so, turn it into a pure batch command!
"\\domainx.com\netlogon.bat"
This would be equivalent to your current VB Script program
but much simpler. It also avoids the timing issue.

"TJCooper1972" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

Running Login Script after establishing a VPN connection

Post by Richard Mu » Sun, 11 May 2008 07:36:59


You bind wshShell to "Scripting.FileSystemObject" instead of
"Wscript.Shell". The FSO has no Run method, while Wscript.Shell does.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.yqcomputer.com/
--
 
 
 

Running Login Script after establishing a VPN connection

Post by Al Dunba » Mon, 12 May 2008 01:48:33

"Pegasus (MVP)" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...

Or, alternately:


The "true" will cause the .run to return only once the batch script has
completed.

/Al



 
 
 

Running Login Script after establishing a VPN connection

Post by VEpDb29wZX » Wed, 14 May 2008 23:11:00

The login script is referenced in the user object login script field. That
calls a batch file with looks at a text file for map drives.

Is there a way to launch the same process that takes place when you log in?
 
 
 

Running Login Script after establishing a VPN connection

Post by VEpDb29wZX » Wed, 14 May 2008 23:13:21

dont know what you mean by a "pure batch command".

"Pegasus (MVP)" wrote:

 
 
 

Running Login Script after establishing a VPN connection

Post by VEpDb29wZX » Wed, 14 May 2008 23:15:01

hanks!!!

It ALMOST works. It tries to disconnect the drive just a tad too soon.


"Al Dunbar" wrote:

 
 
 

Running Login Script after establishing a VPN connection

Post by VEpDb29wZX » Wed, 14 May 2008 23:18:01

So I need to do?

Set Wscript.Shell = CreateObject("Scripting.FileSystemObject")
 
 
 

Running Login Script after establishing a VPN connection

Post by MV » Wed, 14 May 2008 23:20:14


You previously wrote
"I suppose I could call up the text file with the actuall mapped drives
and parse it for UNC paths. Put those UNC paths into an array and
then map them."
This sounded like a good idea to me - what's happened to it?
 
 
 

Running Login Script after establishing a VPN connection

Post by VEpDb29wZX » Wed, 14 May 2008 23:33:02

I have to figure out how to parse the file correctly. I dont do a lot of
scripting, so everything is slow going for me. The file has a number of
mapped drives and commented lines. I can ignore commented lines and focus on
lines that start with a $. This is what I have to parse:

----------

;
; Windows NT and Windows For Workgroups Logon Script
;

$NameLine = "my region"
$HelpDesk = "555-555-5555"

$Drive1 = M:
$Name1 = "drivea"
$Dir1 = "\\server\mapm"

$Drive3 = W:
$Name3 = "driveb"
$Dir3 = "\\server\mapw"

;
; the following should reflect appropriate mapped drive for location
;

$Drive4 = H:
$Name4 = "drivec"
$Dir4 = "\\server\maph"

$Drive5 = P:
$Name5 = "drived"
$Dir5 = "\\server\mapp"

$Drive6 = k:
$Name6 = "drivee"
$Dir6 = "\\server\mapk"

--------------
 
 
 

Running Login Script after establishing a VPN connection

Post by MV » Thu, 15 May 2008 00:48:38


Your reply is a little too vague to give you a precise
recipe but the following batch file may well do the job.
Here is what you need to do:
- Use copy & paste to copy the code into a batch file.
- Adjust Lines 03 and 04 to suit your own environment.
- Remove the line numbers.
- Test the batch file.
- When happy with the result, activate the batch file by
removing the word "echo" on Line 09.

01. @echo off
02. setlocal enabledelayedexpansion
03. set ShareName=$Dir6
04. set ShareList=c:\Shares.txt
05.
06. for /F "tokens=1,2 delims==" %%a in ('type %ShareList%') do (
07. set Share=%%a
08. set Share=!Share: =!
09. if /i !Share!==%ShareName% echo call %%b\netlogon.bat
10. )
Feel free to ask if you want to know how and why the code works.
 
 
 

Running Login Script after establishing a VPN connection

Post by Al Dunba » Thu, 15 May 2008 13:56:04

Wait a minute, the script shown is a kixtart script. Instead of writing a
script in another language, whether batch or vbscript, why not just get
kixtart to run the script?

/Al