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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Triggering a VB exe on shutdown

Status
Not open for further replies.

PruSQLer

Technical User
Nov 6, 2001
221
US
Is there a relatively easy way to have a VB program executed when Windows is shutting down?
 
um im not sure of the practicality of this solution, but could you not have your app running in the background and use the queryunload event to catch the system shutdown?!?

you may need the abortsystemshutdown api to stop windows actually shutting down, im not sure!?

then when your code has executed use the initiatesystemshutdown api.

just an option, but i imagine there will be a much simpler solution somewhere!!

good luck If somethings hard to do, its not worth doing - Homer Simpson
 
Did you want the program to detect a windows shutdown, or you just want the program to run during the shutdown?

Steve
 
I just need to update a file with a few tidbits of info when a shutdown is triggered. The program executes in a split second so it wouldn't be much of an interruption to shutdown, if any. So yes, I want the program to be initiated when a user shuts down the computer.

Why do I want to do this? Because the users asked me to.
 
Depending on the OS, you could use the MMC plug-in, Group Policy Editor (gpedit.msc).

One option is the ability to assign programs to run at startup or shutdown. This can be done for the user or the machine.

Steve
 
if your code is pretty light... you may want to experiment with using the queryunload event of the form...

the unload values you will be interested in are vbAppWindows and vbAppTaskManager.

im pretty sure this will work for you!!

good luck If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top