Windows logoff using Python

vpalade picture vpalade · Jan 10, 2012 · Viewed 7.8k times · Source

Which Python function should I use, to log off current user. I found an example that is locking my pc, like Win+L combination

ctypes.windll.user32.LockWorkStation ()

but I need a similar function, which will log off.

Answer

Sideshow Bob picture Sideshow Bob · Jan 10, 2012

Try os.system("shutdown -l").

shutdown -l is the windows shell command for logoff