farquea Posted July 15, 2011 Author Posted July 15, 2011 Strange... You got a test machine laying around to try something on? Steve yep sure have
Steve21 Posted July 15, 2011 Posted July 15, 2011 Try this, It's not pretty just want to test if it's just the way you're running the logoff that's the issue. testDrive4.zip Obviously needs to run as admin, but then the script would anyway. Just want to see if it works for you, or not or if there's a bigger issue at hand. (Should test H: drive after 10 seconds think that's what you said? (Not sure if you'll need bigger delay, due to slow loading, but we'll see) Steve
farquea Posted July 15, 2011 Author Posted July 15, 2011 Try this, It's not pretty just want to test if it's just the way you're running the logoff that's the issue. [ATTACH=CONFIG]10793[/ATTACH] Obviously needs to run as admin, but then the script would anyway. Just want to see if it works for you, or not or if there's a bigger issue at hand. (Should test H: drive after 10 seconds think that's what you said? (Not sure if you'll need bigger delay, due to slow loading, but we'll see) Steve I just dropped it into the startup folder for all users and logged on as a student, unplugged the cable like they do then locked the worksation and to my joy it still logged them off! - so was this what it should be doing, some sort of check at logon and force a logoff even if the workstation is locked?? If i log on without unplugging though i get a window "Form1" come up saying timer started, timer proc'd and drive mapped i think it is. Then if i try and unplug a cable after this it doesnt log me off (which is exactly what i want as kids have a habit of turning off the wireless switch on their mates laptops, so i'm happy for our current script to just detect this and lock the workstation and kill iexplorer, to carry on doing this) So can you just tell me exactly what this does, in case i've got it a bit wrong or if there is a feature i've not come accross yet and then i guess the question is can we get the form1 window to not be visible at logon?? Thanks again for all your help with this btw.
Steve21 Posted July 15, 2011 Posted July 15, 2011 I just dropped it into the startup folder for all users and logged on as a student, unplugged the cable like they do then locked the worksation and to my joy it still logged them off! - so was this what it should be doing, some sort of check at logon and force a logoff even if the workstation is locked?? If i log on without unplugging though i get a window "Form1" come up saying timer started, timer proc'd and drive mapped i think it is. Then if i try and unplug a cable after this it doesnt log me off (which is exactly what i want as kids have a habit of turning off the wireless switch on their mates laptops, so i'm happy for our current script to just detect this and lock the workstation and kill iexplorer, to carry on doing this) So can you just tell me exactly what this does, in case i've got it a bit wrong or if there is a feature i've not come accross yet and then i guess the question is can we get the form1 window to not be visible at logon?? Thanks again for all your help with this btw. Short answer, It seems the shutdown.exe doesn't like being run through scripted commands. Not sure why, or how. Just reworked the logoff to by like my EduLock style. So it does a WMI call to do it instead. WMI works wonders, love it Basically its working just as you did it originally: Load on startup Wait 10 seconds Check if H exists If yes, do nothing (Ignoring debug output) If no, logoff Would you prefer me to try to rewrite the original script (VBS style) for WMI, or you happy with an exe if I just remove the forms etc? Steve
farquea Posted July 15, 2011 Author Posted July 15, 2011 Short answer, It seems the shutdown.exe doesn't like being run through scripted commands. Not sure why, or how. Just reworked the logoff to by like my EduLock style. So it does a WMI call to do it instead. WMI works wonders, love it Basically its working just as you did it originally: Load on startup Wait 10 seconds Check if H exists If yes, do nothing (Ignoring debug output) If no, logoff Would you prefer me to try to rewrite the original script (VBS style) for WMI, or you happy with an exe if I just remove the forms etc? Steve Thats brilliant, could i ask that you rewrite the original script for WMI. That would be brilliant if you could.
Steve21 Posted July 15, 2011 Posted July 15, 2011 Thats brilliant, could i ask that you rewrite the original script for WMI. That would be brilliant if you could. Can't actually test it, so might take a few attempts But try this please: Dim objNetwork, strUserName, strComputer, WshShell strComputer = "." Const EWX_LOGOFF = 0 Set objNetwork = WScript.CreateObject("WScript.Network") Set WshShell = WScript.CreateObject("WScript.Shell") Set ObjFSO = CreateObject("Scripting.FileSystemObject") WScript.Sleep 5000 strUserName = objNetwork.UserName if strUserName = "Administrator" then else strDomain = objNetwork.userdomain if strdomain = "MLZ" then else if ObjFSO.DriveExists("h:") then else Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//" & strComputer & "/root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true") for each OpSys in OpSysSet OpSys.Win32Shutdown EWX_LOGOFF next End if End if End if Steve
farquea Posted July 15, 2011 Author Posted July 15, 2011 Can't actually test it, so might take a few attempts But try this please: Dim objNetwork, strUserName, strComputer, WshShell strComputer = "." Const EWX_LOGOFF = 0 Set objNetwork = WScript.CreateObject("WScript.Network") Set WshShell = WScript.CreateObject("WScript.Shell") Set ObjFSO = CreateObject("Scripting.FileSystemObject") WScript.Sleep 5000 strUserName = objNetwork.UserName if strUserName = "Administrator" then else strDomain = objNetwork.userdomain if strdomain = "MLZ" then else if ObjFSO.DriveExists("h:") then else Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//" & strComputer & "/root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true") for each OpSys in OpSysSet OpSys.Win32Shutdown EWX_LOGOFF next End if End if End if Steve Just tested it and works like a beauty. thank you so much for everything, been a life saver. i owe you big time!
Steve21 Posted July 15, 2011 Posted July 15, 2011 Just tested it and works like a beauty. thank you so much for everything, been a life saver. i owe you big time! Accepting brown envelopes of cash, huge cakes, or vodka! No problem If you get anymore problems just shout, but as you can see not much to change to update things Steve
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now