I was wondering if it was possible to edit the vbs so that it closed after a short timeout(as it does now) if there were no errors, but either writing an error log to a file on the server or staying open with a message if one/all of the checks fail.
I have very little idea of what to change as I have only just started looking into vb scripting but i'm sure that some of the clever people on here would be able to knock it up in a few minutes.
Just thought it may help for when we get a message saying little johnny couldnt access his work/shared area but no-one actually knows which bit or why.
'check for unplugged network cord during logon
'checks for mapped drives
'merge registry key to run
'| Windows Registry Editor Version 5.00
'| [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Run]
'copy this vbs file to c:\windows directory
Option Explicit ' Added By SM
Dim WshShell, WshNetwork, ObjFSO
Set objNetwork = CreateObject("WScript.Network")
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
' Wait until the user is really logged in... Added by SM
While StrUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
StrUserName = WSHNetwork.UserName ' Get the user name
if strUserName = "Administrator" then
'Ignore the admins ;-) Added By SM
'Check if the home drive is there... Added By SM
if ObjFSO.DriveExists("W:") then
'Yes it is bail out... Added By SM
'No its not, has the network cable been pulled... Added By SM
intReturn = WshShell.Popup("Please ensure the network Cable is plugged in or the Wireless Button is on.", 8, "Login Error", 0)
If intReturn = 1 Then ' Trap the button click... Added By SM
'Wscript.Echo "You clicked the ok button. This would log you off"
Else ' The popup timedout log the user off... Added By SM
'Wscript.Echo "The popup timed out. This would log you off after a timeout"
I had this issue a while back (the network plug being unplugged etc), kids were doing it after login to stop us remoting in etc. I found that the .Net framework as an event which is triggered when the network availability has changed:
System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged += new System.Net.NetworkInformation.NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
void NetworkChange_NetworkAvailabilityChanged(object sender, System.Net.NetworkInformation.NetworkAvailabilityEventArgs e)
// We're back on...
// We've been unplugged... logout...
I'll post a full C# example later which will sit in the background and watch if wanted?