Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduled Tasks to change environmental variables possible

Status
Not open for further replies.

rod602

Technical User
May 16, 2011
66
0
0
US
Morning All

I have a powershell script that pings computers and pulls the logged on user. The script then spits out an html page with that information. There is one case I can't figure out and that is the case when the lower locks his computer and walks away. In the case the user might be long gone but the computer still shows he is logged in.

I know I can solve this by either
1) changing power profiles so computer sleeps/shutdowns after moments of inactivity.
2) Scheduled tasks that runs when computer locks computer .

I am trying to work with 2. In win 7 you can run a script/bat file when the user locks the computer. I created environmental variables to keep track of when the computer is locked by the user( he/she does a windows key + l). So when they lock it I set a variable lock to true and another variable with a time stamp. Then with powershell I can query those variables and figure out if the computer is locked.

The logic makes sense but its not working. The script doesn't seem to change the environmental variables. I am using setx. Maybe users without admin privileges can't change environmental variables?

Any insights/ideas into how to implement this would truly be appreciated.

Rod
 
As I understand it, environment variables are 'there', but not effective until the user logs in again. Do you think maybe the user needs to log out and log in again in order for the variable to be set?


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top