Does anyone know how to run a program before windows shuts down? Like this tool does: http://www.fileware.com/products.htm#LastChance
I don't need to shut down windows myself, what I need is to detect when Windows shuts down, launch a program and when it is finished then carry on shutting windows down. I know you can do it via gpedit.msc but I need to do it by a PB program or batch file. Hope I made sense! Thanks.
Run program before shutdown
Re: Run program before shutdown
You could catch the #WM_QUERYENDSESSION message (http://msdn.microsoft.com/en-us/library ... 85%29.aspx), block shutting down, run the program you need and then shut down yourself.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: Run program before shutdown
Thanks c4s but that's beyond my capability. I just thought someone on the forum might have wanted to do this before and had some code handy.c4s wrote:You could catch the #WM_QUERYENDSESSION message (http://msdn.microsoft.com/en-us/library ... 85%29.aspx), block shutting down, run the program you need and then shut down yourself.
Re: Run program before shutdown
ricardo posted a code example just 3 weeks ago:whertz wrote:I just thought someone on the forum might have wanted to do this before and had some code handy.
http://www.purebasic.fr/english/viewtop ... 12&t=45779
Re: Run program before shutdown
Thanks Shardik. Seems simple enough, but this code would not wait until your program has finished what it is doing, so there could be a problem if windows shuts down too early.Shardik wrote:ricardo posted a code example just 3 weeks ago:whertz wrote:I just thought someone on the forum might have wanted to do this before and had some code handy.
http://www.purebasic.fr/english/viewtop ... 12&t=45779
-
- Enthusiast
- Posts: 252
- Joined: Mon Aug 16, 2010 4:29 am
Re: Run program before shutdown
@whertz
Don't give up on Group Policy if you want to keep this simple. Just add a batch file into the Shutdown folder used by the MMC Group Policy snap-in. You will need admin privileges for MMC setup and to put the .BAT file in the proper folder but once there it can run a PB EXE which will not be cut off. It is easy to have the program look for a command somewhere to tell it what to do so you will not have to edit policy more than once.
Don't give up on Group Policy if you want to keep this simple. Just add a batch file into the Shutdown folder used by the MMC Group Policy snap-in. You will need admin privileges for MMC setup and to put the .BAT file in the proper folder but once there it can run a PB EXE which will not be cut off. It is easy to have the program look for a command somewhere to tell it what to do so you will not have to edit policy more than once.
Re: Run program before shutdown
I need to add the program not just for my computer, but other's as well. This is why I need a PB program to do it, or a batch file or something. So it has to be 'portable' in that it will run the program when the user finishes setting up my program. Can it be added to Group Policy via script? Maybe adding it via registry but that is kinda messy.buddymatkona wrote:@whertz
Don't give up on Group Policy if you want to keep this simple. Just add a batch file into the Shutdown folder used by the MMC Group Policy snap-in. You will need admin privileges for MMC setup and to put the .BAT file in the proper folder but once there it can run a PB EXE which will not be cut off. It is easy to have the program look for a command somewhere to tell it what to do so you will not have to edit policy more than once.