Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run my program on before logout on windows XP?

I am looking for an inverse version of "RunOnceEx".

RunOnceEx does run some program, before the user's shell(desktop&taskbar) start. The login progress will not continue before the runonceex complete.

I want to do exact the same but on user logout. When she/he logout, all running program shutdown, leaving shell(desktop&taskbar), then ""I wish my program will be execute this moment"", finally logout.

I think it is possible because the "mobsync.exe" is doing that. But I cannot find where and how to do it.

like image 725
Dennis C Avatar asked Nov 27 '08 16:11

Dennis C


2 Answers

Warning, as said here, gpedit.msc will allow you to configure a logoff script for all users.

If you need that script only for one user, you need to declare it directly in the registry, both in HKCU and HKLM.

like image 160
VonC Avatar answered Oct 27 '22 05:10

VonC


To run this only for the current user, you can use WMI to get an information when a shutdown/logout occurs.

Either you write a small C# (or any other language that can use WMI) application or vbs script to listen on the Win32_ComputerShutdownEvent WMI event.

An example C# app can be found here in this question: Get Log off event from system

like image 38
Dominik Fretz Avatar answered Oct 27 '22 05:10

Dominik Fretz