Jump to content

Recommended Posts

Posted (edited)

We have a script running which stops kids from unplugging the cable mid logon and not getting our smoothwall settings so that thewy can get on Facebook and YouTube. The problem is they have found out that if they do a Windows Lock while the desktop loads, which is when the script runs, that it overiddes the script and doesnt log them off, they then unlock it and carry on using it.

 

Basically i could do with some VB wizz telling me if there is a way to force the logoff even when the worksation is locked OR to infinitenly loop the script so that it just keeps checking for the conditions every 60 seconds. The script is;

 

Dim objNetwork
Dim strUserName
Dim WshShell

Set objNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set ObjFSO = CreateObject("Scripting.FileSystemObject")

WScript.Sleep 5000

strUserName = objNetwork.UserName
if strUserName = "Administrator" then
else
strDomain = objNetwork.userdomain
if strdomain = "MLZ" then **this is a different domain that 6th formers and college students use who dont have H: drives mapped so can be excluded
else
if ObjFSO.DriveExists("h:") then **this is their home drive, if they do the unplug cable logon then they dont get their network drives and this is the condition we use to determine that they have been messing around, so log them off.
else
WshShell.Run "logoff.exe"
End if
End if
End if

Edited by ZeroHour
Posted

How are you running this, as it should still work fine if the computer is locked or not?

 

Other way to do it, "if" you're not actually cancelling the script is like this:

 

Do Until (ObjFSO.DriveExists("h:") = True)
   WshShell.Run "logoff.exe"
Loop

(or this if that doesn't work)

Do Until ObjFSO.DriveExists("h:")
   WshShell.Run "logoff.exe"
Loop

 

Steve

Posted
get the script to check every 10 seconds because every 60 seconds could mean I could lock the machine, unplug it, unlock it, plug it back in and job done, leaves a BIG window of opportunity at 60 seconds.

 

thats what i want to do but dont know how to write that. If you can tell me how i'd be interested to see.

Posted
thats what i want to do but dont know how to write that. If you can tell me how i'd be interested to see.

 

Why even give them 10 seconds? End of day script will only stay running while pc is locked, and you don't want them to have access to anything. It's not like it's using CPU or anything, when it's locked.

 

Just my two cents :p

 

Steve

Posted
How are you running this, as it should still work fine if the computer is locked or not?

 

Other way to do it, "if" you're not actually cancelling the script is like this:

 

Do Until (ObjFSO.DriveExists("h:") = True)
   WshShell.Run "logoff.exe"
Loop

(or this if that doesn't work)

Do Until ObjFSO.DriveExists("h:")
   WshShell.Run "logoff.exe"
Loop

 

Steve

 

This kidn of worked, when it loops and runs logoff.exe you get a End Process window for explorer.exe. if you click end now, it logs off fine, if you dont and then press cancel and mash the keys a bit, lock it then unlock, the start bar might have dissaperared buy you can still open up the C; drive and run iexplorer and mess about like that. So, nearly but not quite :(

Posted
Why even give them 10 seconds? End of day script will only stay running while pc is locked, and you don't want them to have access to anything. It's not like it's using CPU or anything, when it's locked.

 

Just my two cents :p

 

Steve

 

There has to be an initial wait (we currently have it at 5 seconds) this is so that the H: drive is mapped BEFORE the script check for it, if there is no wait it will just log everyone off we found.

Posted

Think you misunderstood what I meant :p

 

You're already doing a 5second wait. My point being why limit it to 10, or 60 second loops. End of day you want it logged off the instant it's unlocked don't you?

 

And in terms of your its hanging comment, Change your use of logoff.exe to a cmd line, shutdown (with logoff, and force parameters)

 

Steve

Posted
Think you misunderstood what I meant :p

 

You're already doing a 5second wait. My point being why limit it to 10, or 60 second loops. End of day you want it logged off the instant it's unlocked don't you?

 

And in terms of your its hanging comment, Change your use of logoff.exe to a cmd line, shutdown (with logoff, and force parameters)

 

Steve

 

That 5 second wait is a waint until it actually runs the IF's part of the script. So windows loads, it runs the script, waits 5 seconds then checks for the conditions, if they aren't met it logs off. Without the 5 second wait EVERYONE gets logged off because it runs before the H: Drive is mapped. However if you lock the workstation before the desktop has loaded, the script runs but doesnt log you off if the workstation is locked. After this has run, they unlock and free to do as they wish. So i need the script to loop, constantly checking for a H: drive, which at the moment it isnt doing, its only looking once. But i dont know how to do this as this script was taken from from this site in the first place.

Posted

And as I said three times :p you don't need "BOTH" timers :p

 

You have a 5 second timer. That's fine.

 

You don't need the loop to be on a 10/60/250505050 second loop, there's no benefit to it. :D

 

Steve

Posted
And as I said three times :p you don't need "BOTH" timers :p

 

You have a 5 second timer. That's fine.

 

You don't need the loop to be on a 10/60/250505050 second loop, there's no benefit to it. :D

 

Steve

 

Ok so what do i need to change then to achieve what i want to do? as like i said i know very little about VB.

Posted

Err haven't tested, as I'd prefer not to autokill myself as I don't have H drive :D

 

But this should work, gimme a shout if it's not

 

Dim objNetwork
Dim strUserName
Dim WshShell

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

Do Until ObjFSO.DriveExists("h:")
   WshShell.Run "shutdown /l /f /t 0"
Loop

End if
End if
End if

 

Steve

Posted (edited)
Err haven't tested, as I'd prefer not to autokill myself as I don't have H drive :D

 

But this should work, gimme a shout if it's not

 

Dim objNetwork
Dim strUserName
Dim WshShell

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

Do Until ObjFSO.DriveExists("h:")
   WshShell.Run "shutdown /l /f /t 0"
Loop

End if
End if
End if

 

Steve

 

It kind oif works but..... when you unlock the script starts the logoff but you get a ticker box ending explorer.exe then if you press "end now" it obviously logs off like it shoud but if you press cancel you can get Internet Explorer Open and ignore the attempt at trying to logoff and you can carry on use iexplorer. would you know how to add in a line in the loop to kill iexplorer.exe so that if its open it gets closed and if its opened again just keeps getting closed (if it would work like that)

Edited by farquea
Posted

Any idea what it's hanging on? It should only hang if something is open normally.

 

To kill IE this should work: (again, will need to test it :p Don't like killing my stuff :D)

 

Set objShell = CreateObject("Wscript.Shell") 
objShell.Run("taskkill /im iexplore.exe"), 1, TRUE 

Posted
Any idea what it's hanging on? It should only hang if something is open normally.

 

To kill IE this should work: (again, will need to test it :p Don't like killing my stuff :D)

 

Set objShell = CreateObject("Wscript.Shell") 
objShell.Run("taskkill /im iexplore.exe"), 1, TRUE 

 

On further testing, sometimes it does log the user straight off after you unlock, sometimes it gets stuck in the logoff process but get the trying to end explorer.exe process i described above BUT i dont think they can actually get anything to load when its in this state, although i've not exhaustivly checked this. Because i'm a VB noob, where exactly would i put that line to kill iexplorer.exe? above the shutdown line (i changed it to logoff on mine)?

Thanks for all your help, i really appreciate it!

Posted
Any idea what it's hanging on? It should only hang if something is open normally.

 

To kill IE this should work: (again, will need to test it :p Don't like killing my stuff :D)

 

Set objShell = CreateObject("Wscript.Shell") 
objShell.Run("taskkill /im iexplore.exe"), 1, TRUE 

 

On further testing, sometimes it does log the user straight off after you unlock, sometimes it gets stuck in the logoff process but get the trying to end explorer.exe process i described above BUT i dont think they can actually get anything to load when its in this state, although i've not exhaustivly checked this. Because i'm a VB noob, where exactly would i put that line to kill iexplorer.exe? above the shutdown line (i changed it to logoff on mine)?

Thanks for all your help, i really appreciate it!

Posted
On further testing, sometimes it does log the user straight off after you unlock, sometimes it gets stuck in the logoff process but get the trying to end explorer.exe process i described above BUT i dont think they can actually get anything to load when its in this state, although i've not exhaustivly checked this. Because i'm a VB noob, where exactly would i put that line to kill iexplorer.exe? above the shutdown line (i changed it to logoff on mine)?

Thanks for all your help, i really appreciate it!

 

On further testing, sometimes it does log the user straight off after you unlock, sometimes it gets stuck in the logoff process but get the trying to end explorer.exe process i described above BUT i dont think they can actually get anything to load when its in this state, although i've not exhaustivly checked this. Because i'm a VB noob, where exactly would i put that line to kill iexplorer.exe? above the shutdown line (i changed it to logoff on mine)?

Thanks for all your help, i really appreciate it!

 

Easiest way would be just adding it as such:

 

Do Until ObjFSO.DriveExists("h:")
   WshShell.Run("taskkill /im iexplore.exe"), 1, TRUE
   WshShell.Run "shutdown /l /f /t 0"
Loop

 

It's the same wshshell var. so can just rename it to get rid of a line.

 

And your comment on "change it to a logoff", Mine WAS a logoff :D shutdown /l (logoff) /f (force) /t 0 (0 seconds)

 

Steve

Posted
seems the script still isnt stopping them, it looks like if they pull the network cable at the right time, somehow it doesnt work because kids are still getting on facebook, youtube etc. So starting to run out of ideas, if anyone has anything else we could try it would be greatly appreciated!
Posted
seems the script still isnt stopping them, it looks like if they pull the network cable at the right time, somehow it doesnt work because kids are still getting on facebook, youtube etc. So starting to run out of ideas, if anyone has anything else we could try it would be greatly appreciated!

 

I don't mean to sound really patronising here, but I'm assuming you are running the script locally, not off a network? aka, It's not that it's just not downloading/accessing the script in the first place?

 

Totally different option, could take a look at EduLock below :p

 

Steve

Posted

problem is staff use youtube and its not just facebook and youtube, its lots of other sites like game sites. My colleague is looking at denying all internet access to unauthenticted users which would solve it, except that then causes problems for some of our servers, such as anti virus updates and the same amount of computers we have on the network that are connected but not on the domain, such as staff ipdas and phones etc.

 

As they are locking the workstation to prevent the logoff script from running, i'm thinknig how easy would it be to put something together that either disables all keyboard input for the first 10 seconds or the ability to lock the worksation, and so that it only is enabled after 10 seconds...... although i'm not sure a) if they will still be able to prevent a script like that running or if its even possible to do as i wouldnt have a clue where to start trying to script something like that :(

Posted
I don't mean to sound really patronising here, but I'm assuming you are running the script locally, not off a network? aka, It's not that it's just not downloading/accessing the script in the first place?

 

Totally different option, could take a look at EduLock below :p

 

Steve

 

the script is copied to the windows directory and run on startup.

Posted
the script is copied to the windows directory and run on startup.

 

Copied as in, "always there". Or copied as in "on logon".

 

Just if they're disconnecting it before you're copying it over, (if doing on logon) it wouldn't work.

 

Steve

Posted
Copied as in, "always there". Or copied as in "on logon".

 

Just if they're disconnecting it before you're copying it over, (if doing on logon) it wouldn't work.

 

Steve

 

copied so that its always there yes

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