Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Check if somebody is logged on or computer is locked?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,30019
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Check if somebody is logged on or computer is locked?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Check if somebody is logged on or computer is locked? - 1/17/2006 11:53:50 PM   
  electro

 

Posts: 52
Score: 0
Joined: 10/17/2005
Status: offline
I want to run certain scripts at night but I want them not to run if there is a user logged on or if the computer is locked?
How do I do that?
 
 
Post #: 1
 
 RE: Check if somebody is logged on or computer is locked? - 1/18/2006 5:52:16 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
I'm not sure if there is a way to check this purely through VBS; I started using psloggedon.exe and so I never looked any further into VBS for it.
www.sysinternals.com

Here's a little snippet of code for using that program.
You will just need to download the psloggedon.exe then alter "PSL", "strComputer", "DOM"


      

< Message edited by Country73 -- 1/18/2006 5:54:52 AM >

(in reply to electro)
 
 
Post #: 2
 
 RE: Check if somebody is logged on or computer is locked? - 1/19/2006 8:32:30 PM   
  ginolard


Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
You could just check if Explorer.EXE is running.

It's only ever running if a user is logged on and, for a machine to be locked, there needs to be a user logged on ;)

(in reply to Country73)
 
 
Post #: 3
 
 RE: Check if somebody is logged on or computer is locked? - 1/20/2006 12:18:54 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
That's seems to be a more simplified way of verifying a user is logged in or not.
I guess I'm just used to my little script with psloggedon since I'm able to extract the UserName if someone is actually logged in.

(in reply to ginolard)
 
 
Post #: 4
 
 RE: Check if somebody is logged on or computer is locked? - 1/20/2006 12:54:52 AM   
  crazymatt

 

Posts: 296
Score: 0
Joined: 3/4/2005
From:
Status: offline
Try this!


      

And as ginolard said, if noone is logged on it cant be locked ;)

Hope it helps!

/CM

_____________________________

-There is only 10 sorts of people, those who understand binary and those who dont.

(in reply to Country73)
 
 
Post #: 5
 
 RE: Check if somebody is logged on or computer is locked? - 1/20/2006 1:13:02 AM   
  ginolard


Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
Crazymatt,

That script is fine but it won't detect users who are logged on locally.  I had exactly the same issue when developing ManagePC and the only way I could retrieve the logged-on user with any accuracy was to check the owner of the EXPLORER.EXE process.

Matt

(in reply to crazymatt)
 
 
Post #: 6
 
 RE: Check if somebody is logged on or computer is locked? - 1/22/2006 6:39:12 PM   
  crazymatt

 

Posts: 296
Score: 0
Joined: 3/4/2005
From:
Status: offline
Oh, didnt know that. I dont have any local users though so it havnt been a problem for me.
But its good to know and i will add in the explorer.exe check as an extra IF statement when i have some spare time :)

Regards
CM

_____________________________

-There is only 10 sorts of people, those who understand binary and those who dont.

(in reply to ginolard)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Check if somebody is logged on or computer is locked? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts