PEO Posted April 6, 2011 Posted April 6, 2011 We have an issue with kids disconnecting the network cable from the back so it releases the machine from netschool support. Can someone help me by writing a quick script to blank the screen with a message when the student disconects the network cable. I found this script which shows a message but thats about it. strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\wmi") Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ ("Select * from MSNdis_StatusMediaDisconnect") Do While True Set strLatestEvent = colMonitoredEvents.NextEvent Wscript.Echo "A network connection has been lost:" WScript.Echo strLatestEvent.InstanceName, Now Wscript.Echo Loop I'm not a script person, but i think if the screen was blanked it would make the machine useless and deture the student from messing about. Can anyone help? Cheers in advanced Kev
PEO Posted April 6, 2011 Author Posted April 6, 2011 sorry here is the correct script strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\wmi") Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ ("Select * from MSNdis_StatusMediaDisconnect") Do While True Set strLatestEvent = colMonitoredEvents.NextEvent Wscript.Echo "A network connection has been lost:" WScript.Echo strLatestEvent.InstanceName, Now Wscript.Echo Loop
Steve21 Posted April 6, 2011 Posted April 6, 2011 Maybe check out: http://www.edugeek.net/forums/windows/73182-deterring-kids-unplugging-network-cables.html Does what you ask, but without blanking. Based on locking the computers. Blanking screens, and locking access is a bit "over script" If that's no use, gimme a shout and I'll see what I can do. Steve
PEO Posted April 6, 2011 Author Posted April 6, 2011 Hi Steve, I like the last script Option Explicit Dim strHost strHost = "10.64.65.1" PingForever strHost Sub PingForever(strHost) Dim Shell, strCommand, ReturnCode Set Shell = CreateObject("wscript.shell") strCommand = "ping -n 1 -w 300 " & strHost While(True) ReturnCode = Shell.Run(strCommand, 0, True) If ReturnCode = 0 Then Else Shell.Run "rundll32 user32.dll,LockWorkStation" Dim objWMIService, objProcess, colProcess Dim strComputer, strProcessKill strComputer = "." strProcessKill = "'iexplore.exe'" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colProcess = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = " & strProcessKill ) For Each objProcess in colProcess objProcess.Terminate() Next End If Wscript.Sleep 5000 Wend End Sub can it be tweeked to the do the following as locking student accounts dosent is disabled for students. Can it show an image that covers the screen bit like the lockout screen that they get when the teacher locks their computer? when they reconnect it removes the lockout screen.
srochford Posted April 6, 2011 Posted April 6, 2011 I've added a bit at http://www.edugeek.net/forums/windows/73182-deterring-kids-unplugging-network-cables-5.html#post659654 which I hope clarifies what's needed. @Steve21 - not sure what you mean by "a bit over script"??
Steve21 Posted April 6, 2011 Posted April 6, 2011 @Steve21 - not sure what you mean by "a bit over script"?? Blanking the screen, and disabling all commands that override it aka, keyboard, mouse, ctrlaltdel etc is a bit "over complicated" for vbscript Not sure it can do what you want without proper libraries etc, (C etc etc) Steve
PEO Posted April 6, 2011 Author Posted April 6, 2011 just a blank screen with an image is enough. it would make the machine useless them
Steve21 Posted April 6, 2011 Posted April 6, 2011 just a blank screen with an image is enough. it would make the machine useless them And someone could just alt-tab it etc You need to disable many more things that just putting a blank image up, as I've been messing around with trying to do a version of this on our system. Same with control-alt-del, it's built in to always take priority etc etc. Steve
srochford Posted April 6, 2011 Posted April 6, 2011 Blanking the screen, and disabling all commands that override it aka, keyboard, mouse, ctrlaltdel etc is a bit "over complicated" for vbscript Not sure it can do what you want without proper libraries etc, (C etc etc) Steve The beauty of vbscript (and other scripting languages) is that they can all functions in the OS which do everything you want - in this case it's just using rundll to do the actual locking and using WMI to monitor what's going on. Doing this gives you just as much power as any language. What you typically don't get is speed (every command is interpreted every time it's executed) but that just doesn't matter for a job like this.
Steve21 Posted April 6, 2011 Posted April 6, 2011 The beauty of vbscript (and other scripting languages) is that they can all functions in the OS which do everything you want - in this case it's just using rundll to do the actual locking and using WMI to monitor what's going on. Doing this gives you just as much power as any language. What you typically don't get is speed (every command is interpreted every time it's executed) but that just doesn't matter for a job like this. Ok then, so how would you blank the screen out using vbscript? Never found a way to do it. Steve
srochford Posted April 6, 2011 Posted April 6, 2011 Ok then, so how would you blank the screen out using vbscript? Never found a way to do it. No idea :-) How would you do it from C/VB.Net, whatever? One thing that comes to mind is that you could have a theme with all colours set to black (or all white or whatever) and just set that. Is There a Silent Command-Line Operation to change theme? - Windows 7 Forums has a vbscript which will change theme; in the example it just uses one of the existing themes but I'm sure you could create an "all black" theme to use.
Steve21 Posted April 6, 2011 Posted April 6, 2011 No idea :-) How would you do it from C/VB.Net, whatever? One thing that comes to mind is that you could have a theme with all colours set to black (or all white or whatever) and just set that. Is There a Silent Command-Line Operation to change theme? - Windows 7 Forums has a vbscript which will change theme; in the example it just uses one of the existing themes but I'm sure you could create an "all black" theme to use. Well yeah, but all black theme, still gives full access to any programs, commands etc Just black background etc etc. As I said originally only way I can think of doing it is with additional libraries etc, and not in a script But meh. Assumed you knew a way the way you said it Guess I'll keep playing around with code Steve
round2it Posted April 6, 2011 Posted April 6, 2011 how about this script "get the teachers to control the kids" "job fixed" works for me the problem is not with the system it is a classroom management issue 1
AyatollahPies Posted April 6, 2011 Posted April 6, 2011 how about this script "get the teachers to control the kids" "job fixed" works for me the problem is not with the system it is a classroom management issue Couldn't agree more. I think we often make things harder for ourselves by trying to automate everything.
srochford Posted April 6, 2011 Posted April 6, 2011 Well yeah, but all black theme, still gives full access to any programs, commands etc Just black background etc etc. As I said originally only way I can think of doing it is with additional libraries etc, and not in a script But meh. Assumed you knew a way the way you said it Guess I'll keep playing around with code Apologies if you misunderstood what I wrote - I didn't say anything about blanking the screen! You're talking about "playing around with code" but, ultimately, your code has to call functions built into the OS and scripts can do that just as well - scripting *is* programming. If you start using Powershell rather than VBScript you've got access to pretty much anything you could do "in code" - it just might run a bit more slowly. This means that you wouldn't write a 3D game in VBScript or Powershell but a utility type program which is executed only once per session doesn't need to run at top speed. To be honest, I don't really know why you want to blank the screen rather than lock the computer. If the intention is to stop people unplugging the network cable then locking the computer when the cable is unplugged seems a pretty good way of doing that - you can't play games or do anything else "off task" when the computer is locked!
PEO Posted April 7, 2011 Author Posted April 7, 2011 rather than locking the computer what would be line for logging them off?
Steve21 Posted April 7, 2011 Posted April 7, 2011 rather than locking the computer what would be line for logging them off? WshShell.Run "logoff.exe" Should work fine, 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