
FYI: Win2k Login Script Not Running
Hi all!
I've run into people on many occasions that have a hard time with the fact
that Win2k has some weirdness in that if you log in to a notebook with your
cached information, then use DUN to connect to your domain your login
scripts won't run.
This is documented by Microsoft as being the case--although it works in XP.
I've seen many work arounds for this including the correct way--what I call
correct--that you check the 'login with dialup networking' check box at the
CTL-ALT-DEL screen. I've never seen a work around for this that would let
the user recieve the popup warning them that their password is going to
expire. Which was a problem in our environment. I know alot of people
recommend the CMAK but eww that is like a lot of work.
To the point:
I've written a script with VBS and WMI that monitors the local network
adapters instances for a WAN instance to be created (i.e. dialup). If and
when this occurs it will calculate password expiration and can trigger a
remote--centrally managed--login script via a WSH shell. You would need to
deploy this script to each of your remote users and put it in their 'start
up' folder. It isn't perfect--as ADSI is SLOW--but maybe it will help
someone.
Any comments questions welcome.
Here is the script:
-------------------------------------------------------------
'WMI Login Watcher: By SGN Craig - Free to use. Please do not remove this
tag.
Dim Event1 ' Holds the Object that the event raises
Dim EventInstance ' Holds an Instance of the event object
Set Event1 = GetObject("winmgmts:").ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA
'Win32_PerfRawData_Tcpip_NetworkInterface'")
Do
Set EventInstance = Event1.NextEvent
If Instr(EventInstance.TargetInstance.Name, "WAN") > 0 Then Exit Do
Loop
Set EventInstance = Nothing
Set Event1 = Nothing
Dim WshNetwork ' Holds network methods
Dim UserName ' Holds User Name
Dim USR ' Holds User Object from AD
Dim DaysLeft ' Holds number of days until password expires
Dim WshShell ' Holds shell script methods
Set WshNetwork = WScript.CreateObject("WScript.Network")
UserName = WshNetwork.UserName
Set WshNetwork = Nothing
Set USR = GetObject("WinNT://ENTERYOURDOMAIN/" & UserName & ",User")
DaysLeft = DateDiff("d", Now(), USR.PasswordExpirationDate)
Set USR = Nothing
If DaysLeft < 300 Then 'Obviously the 300 is for testing only
Wscript.Echo "You password will expire in " & DaysLeft & " days."
End If
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run \\ENTERYOURPATH\login.vbs ' Gotta use IP not machine name
here. Resolution won't be working yet.
Set WshShell = Nothing