+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
Scripts Thread, can anyone help me out in Coding and Web Development; We have an issue with kids disconnecting the network cable from the back so it releases the machine from netschool ...
  1. #1
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,095
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72

    can anyone help me out

    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.

    Code:
    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

  2. #2
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,095
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    sorry here is the correct script

    Code:
    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

  3. #3

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,697
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Maybe check out:

    Deterring Kids From Unplugging Network Cables

    Does what you ask, but without blanking. Based on locking the computers.

    Blanking screens, and locking access is a bit "over script" :P

    If that's no use, gimme a shout and I'll see what I can do.

    Steve

  4. #4
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,095
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    Hi Steve, I like the last script

    Code:
    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.

  5. #5

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    I've added a bit at Deterring Kids From Unplugging Network Cables which I hope clarifies what's needed.

    @Steve21 - not sure what you mean by "a bit over script"??

  6. #6

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,697
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by srochford View Post
    @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

  7. #7
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,095
    Thank Post
    457
    Thanked 152 Times in 96 Posts
    Rep Power
    72
    just a blank screen with an image is enough. it would make the machine useless them

  8. #8

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,697
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by PEO View Post
    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

  9. #9

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Quote Originally Posted by Steve21 View Post
    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.

  10. #10

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,697
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by srochford View Post
    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

  11. #11

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Quote Originally Posted by Steve21 View Post
    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.

  12. #12

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,697
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by srochford View Post
    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 Guess I'll keep playing around with code

    Steve

  13. #13
    round2it's Avatar
    Join Date
    May 2009
    Location
    UK
    Posts
    1,015
    Thank Post
    199
    Thanked 148 Times in 105 Posts
    Rep Power
    38
    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

  14. #14
    AyatollahPies's Avatar
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    900
    Thank Post
    48
    Thanked 105 Times in 95 Posts
    Rep Power
    42
    Quote Originally Posted by round2it View Post
    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.

  15. #15

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Quote Originally Posted by Steve21 View Post
    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 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!

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •