How do I get #WM_QUIT on reboot?

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 2183
Joined: Sun May 14, 2017 1:48 am

Re: How do I get #WM_QUIT on reboot?

Post by AZJIO »

link1
link2 shortened
The program creates shortcuts when inserting a flash drive and deletes them when removing the flash drive.
User avatar
HeX0R
Addict
Addict
Posts: 1201
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: How do I get #WM_QUIT on reboot?

Post by HeX0R »

Shortcuts, which are doing what exactly?
Randy Walker
Addict
Addict
Posts: 1058
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: How do I get #WM_QUIT on reboot?

Post by Randy Walker »

Axolotl wrote: Tue Oct 05, 2021 3:50 pm Example : delete file at next Windows startup

Code: Select all

MoveFileEx_("Some_file_i_dont_need_anymore", 0, #MOVEFILE_DELAY_UNTIL_REBOOT)  
MSDN: If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.
This is some primo information. THANKS Aristotle!!!! :D
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1058
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: How do I get #WM_QUIT on reboot?

Post by Randy Walker »

Randy Walker wrote: Fri Aug 29, 2025 9:35 pm
Axolotl wrote: Tue Oct 05, 2021 3:50 pm Example : delete file at next Windows startup

Code: Select all

MoveFileEx_("Some_file_i_dont_need_anymore", 0, #MOVEFILE_DELAY_UNTIL_REBOOT)  
MSDN: If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.
This is some primo information. THANKS Aristotle!!!! :D
Well. I thought it was a really great tip but cannot get it to work for me. I tried two ways:

Code: Select all

MoveFileEx_("Some_file_i_dont_need_anymore", 0, #MOVEFILE_DELAY_UNTIL_REBOOT)
AND:

Code: Select all

D$ = "Some_file_i_dont_need_anymore"
MoveFileEx_(@D$, 0, #MOVEFILE_DELAY_UNTIL_REBOOT)
Guess I'm missing something. I don't know.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1058
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: How do I get #WM_QUIT on reboot?

Post by Randy Walker »

Axolotl wrote: Tue Oct 05, 2021 3:50 pm Example : delete file at next Windows startup

Code: Select all

MoveFileEx_("Some_file_i_dont_need_anymore", 0, #MOVEFILE_DELAY_UNTIL_REBOOT)  
I had no luck getting this trick to work but I did a lot of research and hacking to find a way for an EXE to delete itself. The answer is here:
viewtopic.php?p=644643#p644643
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Axolotl
Addict
Addict
Posts: 832
Joined: Wed Dec 31, 2008 3:36 pm

Re: How do I get #WM_QUIT on reboot?

Post by Axolotl »

@Randy Waler:
To delete or rename a file, you must have either delete permission on the file or delete child permission in the parent directory.
More on this functions: MoveFileExW function (winbase.h)

The function stores the locations of the files to be renamed at restart in the following registry value:

Code: Select all

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
BTW: The batch solution is a quite good one.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Randy Walker
Addict
Addict
Posts: 1058
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: How do I get #WM_QUIT on reboot?

Post by Randy Walker »

Axolotl wrote: Sat Aug 30, 2025 10:50 am @Randy Waler:
To delete or rename a file, you must have either delete permission on the file or delete child permission in the parent directory.

BTW: The batch solution is a quite good one.
I figured it was a permissions issue preventing your solution from working for me and decided best not to pursue it further since I would have no control over that on the end users machine. The bat solution fit the bill perfectly for me and has the added benefit of immediate cleanup, as opposed to waiting for next reboot, or forcing an unexpected reboot. In my case the Uninstall is not for user discretion. It is for banishment, removing all traces of the app and associated data on employees that have left the company. They can't restore and run from backup because the same cleanup will occur. This bat thing is the last part of cleanup that was missing from my banish procedure.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Post Reply