Right, I know next to nothing about coding. It's not something I've ever enjoyed or wanted to do, but sometimes it becomes a necessity in my job and this current problem has me stumped.
We've got a bunch of clever shit kids at the moment that have worked out how to bypass all of the group policies set for our Windows 7 desktops by removing the network cables for said machines at certain points in time. They pull it out on a reboot so that it gets none of the machine policies and then put it back in. They log in and then pull it out again after about 10 seconds so that they don't get all of their user policies either. That seems to get Windows 7 giving them some kind of default profile that enables them to get to the run command, regedit and the C drive. This gives them the power to do what they like (which is usually to uninstall the anti-virus, install a remote tool and then piss off any users on that machine afterwards). We never had this problem with Xp, so I don't know why Windows 7 makes it so easy to get full rights in.
Anyway, lots of people on forums suggest using a script to do it that runs as they log in. It checks to see if they've got a mapped home drive (as that's one of the last things to be done in a GPO) and if it's not there, logs them off again. I'll post the script below. The problem I'm having is that my machines don't seem to run this script if i run it via the registry, which is what they're all suggesting. They say to put an entry in HKLM->Software->Microsoft->Windows->CurrentVersion->Run that runs the .vbs file, but it just doesn't seem to run... as anyone. If I run the script myself however, it runs fine.
Any ideas? Do I have to be really specific with what I put in the registry entry? I've tried the path it lives in, the path it lives in with either wscript and cscript at the start and also used double "\\" in the path as someone suggested that, but no luck.
Code:
'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\CurrentVersion\Run]
'| "check-home-dir"="\"C:\\WINDOWS\\vbs_logoff.vbs\""
'copy this vbs file to c:\windows directory
Option Explicit ' Added By SM
Dim objNetwork
Dim strUserName
Dim WshShell, WshNetwork, ObjFSO
Dim intReturn
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
Wend
if strUserName = "Administrator" then
'Ignore the admins ;-) Added By SM
else
'Check if the home drive is there... Added By SM
if ObjFSO.DriveExists("z:") then
'Yes it is bail out... Added By SM
else
'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"
WshShell.Run "logoff.exe"
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"
WshShell.Run "logoff.exe"
End If
End if
End if