Logoff Script help?

D

Dan

Hello,
I have a scenario where my VPN users are logging on to
their machines (sort of) before they connect to the
domain. What happens is they logon with cached
information and then VPN in. What I'm seeing is that
after they connect and attempt to logout the logoff script
they're supposed to run is hanging and they are getting
stuck at the "Running Logoff Scripts" prompt.
The script is a .vbs that simply has them choose Yes/No to
copy some data. What should the behavior be here? Why is
it hanging? I have the "Run Visible" option set and I
would think that would be fine. I suspect the VPN tunnel
is closing too quickly for the logoff script to execute
but I can't be sure. Can this be handled somehow?
Thanks,
Dan
 
P

Paul Bergson

You could trigger the logon script using wmi, thereby forcing users to
authenticate which would then allow them to logoff. Track down the November
2002 Windows & .Net magazine. They have a article that I played with and
have script in there for laptops to run a logon script even with cached
credentials.

The unmodified script is below:



' Jeff Payne

'United States Re: SL not running on VPN client posted: 12/3/2002 12:35:09
PM





'The VB script below works for us on XP and 2K. The idea was borrowed from a
magazine article and updated/cleaned up for our environment. Group policy -
User \GroupPolicy\User\Scripts\Logon\vpn.vbs this basically runs as a
listener service waiting for the target network to come up then runs the
login script.

'We want Scriptlogic to add a listener function to Scriptlogic!!!

'Jeff

'VBScript Code:



' Simple VPN / RAS / Dynamic IP Logon Monitor

aSubnetList = Array("134.156.0.0/255.255.0.0")

bAllMatches = True

Set Events = GetObject("winmgmts:\\.\root\cimv2").ExecNotificationQuery
("SELECT TargetInstance.Name FROM __InstanceOperationEvent WITHIN 4 WHERE
TargetInstance ISA 'Win32_NetworkAdapterConfiguration'")

Do

Set oConnectEvent = Events.nextevent

If VarType(oConnectEvent.TargetInstance.Ipaddress(0)) = 8 Then

bFoundMatch = SubnetMatch(aSubnetList,
oConnectEvent.TargetInstance.Ipaddress(0), bAllMatches, aListofMatches)

End If

If bFoundMatch Then

Set oShell = CreateObject("wscript.shell")

Set oNet = CreateObject("Wscript.Network")

On Error Resume Next

oNet.RemoveNetworkDrive "X:", True, True

oNet.MapNetworkDrive "X:", "\\userp\pbergson$"

Err.clear

RunCmd = oShell.Run("x:\doesnt_exist.bat", 1, True)

Err.clear

oNet.RemoveNetworkDrive "R:", True, True

Err.clear

On Error GoTo 0

bFoundMatch = False

End If

Loop

Private Function SubnetMatch(aSubnetsToMatch, IPAddress, bAllMatches,
aMatchList)

For each subnetpair in aSubnetsToMatch

pair = split(subnetpair, "/", 2)

subnetoctets = split(pair(1), ".", 4)

ipaddroctets = split(IPAddress, ".", 4)


If pair(0) = join(Array(ipaddroctets(0) and subnetoctets(0), ipaddroctets(1)
and subnetoctets(1), ipaddroctets(2) and subnetoctets(2), ipaddroctets(3)
and subnetoctets(3)),".") Then

SubnetMatch = True

If MatchList = "" Then

MatchList = MatchList & subnetpair

Else

MatchList = MatchList & ", " & subnetpair

End If

If not bAllMatches Then

aMatchList = Array(subnetpair)

Exit For

End If

End If


Next


If SubnetMatch Then

aMatchlist = split(matchlist, ",")

End If


End Function





--

Paul Bergson MCT, MCSE, MCSA, CNE, CNA, CCA

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Logoff script for single user 1
logoff scripts? 2
Logon script wait screen? 2
Logoff Script for Reminder Message 0
Shutdown on Logoff 1
Script? 4
Display popup on logoff 1
Running logoff script for local user 3

Top