0

We've got a plan to write a script or develop c# code to detect all users that lock their system instead of logging off so we can force them to log off by programming.

I couldn't find anything nothing in the search results.

Maybe there are two step required:

first : how can we detect by which user a system is locked?

second : how can we log off that user?

shutdown.exe -l -t 1

/optionally :

Is there any way to prompt them before lock? To save their open documents??
Gorgsenegger
  • 7,356
  • 4
  • 51
  • 89
saber tabatabaee yazdi
  • 4,404
  • 3
  • 42
  • 58
  • 2
    first: exact duplicate of [How can I programmatically determine if my workstation is locked?](http://stackoverflow.com/questions/44980/how-can-i-programmatically-determine-if-my-workstation-is-locked) second: exact duplicate of http://stackoverflow.com/questions/484278/log-off-user-from-win-xp-programmatically-in-c-sharp – Dennis Jun 18 '13 at 06:10
  • Would you like to prompt them before they *locking* their system or before you are *logging* them *off*? – Gorgsenegger Jun 18 '13 at 06:33
  • 4
    Why do you want to cause users who are used to the way windows works to suddenly be faced with such a hostile change in behaviour? Admins have always had the ability to force users off if you need to obtain access to the system and the user has wondered away having left the system locked. – Damien_The_Unbeliever Jun 18 '13 at 06:41
  • This question would have a better place in SuperUser, though –  Jun 18 '13 at 06:46

1 Answers1

3

You don't need bat or c# for that, just adjusting CNS, Corporate Nazi Settings. Also known as "Group Policies".
You can also find all the different options if (e.g.) you start up gpedit.msc. A good starting point is Administrative Templates --> System --> Ctrl+Alt+Del Options.
Here you can remove lock. One also can adjust lock so instead of locking it'll log the user off.