Using windows logoff process with XP task scheduler logs off run as user instead of current user
Posted on 2009-07-09
I have created a batch file which simply calls on the windows logoff.exe process located in c:\windows\system32\logoff.exe
I then created a scheduled task to call on this batch file. By default, windows scheduler pulls the currently logged on user which is fine for that profile and the batch file executes perfectly. The user is logged out and all is well.
However, this is a business environment and many users log into this PC. For security purposes we want this machine to run the logoff process if the PC has been idle for 30 minutes. All conditions such as these can be specified very easily in the windows scheduler.
Problem: The problem lies in that if a user logs in and becomes idle thereby triggering the process, the "run as" user which is a local administrator on the PC runs the process and because the process is logoff that virtual secondary logon session is terminated instead of the current user logged into the PC. I have tried running as the system account and that did not work either.
Workaround: Entering "shutdown -r" in the batch file to reboot the PC does not log off the user running the process thereby allowing it to work as designed. It logs of the user who is logged into the pc as I would like.
I apologize if this is wordy but if anyone has any thoughts it would be much appreciated.