Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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.

Posted

@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 :p Not sure it can do what you want without proper libraries etc, (C etc etc)

 

Steve

Posted
just a blank screen with an image is enough. it would make the machine useless them

 

And someone could just alt-tab it etc :p 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

Posted
Blanking the screen, and disabling all commands that override it aka, keyboard, mouse, ctrlaltdel etc is a bit "over complicated" for vbscript :p 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.

Posted
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

Posted
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.

Posted
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 :p 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 :p But meh. Assumed you knew a way the way you said it :D Guess I'll keep playing around with code

 

Steve

Posted

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

  • Thanks 1
Posted
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.

Posted
Well yeah, but all black theme, still gives full access to any programs, commands etc :p 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 :p But meh. Assumed you knew a way the way you said it :D 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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...