Jump to content

Using _WinAPI_MoveFileEx with $MOVE_FILE_DELAY_UNTIL_REBOOT


Go to solution Solved by trancexx,

Recommended Posts

Posted

My understanding of the Using the _WinAPI_MoveFileEx with the $iFlags option set to $MOVE_FILE_DELAY_UNTIL_REBOOT, a file (full path name) should be able to be specified as the $sExistingFile option, and 0 specified as the $sNewFile option, and the file will be deleted on the next reboot.

I've tried the following code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=1.0.0.2
#AutoIt3Wrapper_Run_After=copy /Y "%out%" "C:\Temp\*.*"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <WinAPIFiles.au3>

MsgBox ( 0, '@ScriptFullPath - Version', @ScriptFullPath & @CRLF & 'Version: ' & FileGetVersion ( @ScriptFullPath) )

Local $Ret = _WinAPI_MoveFileEx ( 'C:\Temp\MovFileExTest.exe', 0, $MOVE_FILE_DELAY_UNTIL_REBOOT )

MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$Ret' & @CRLF & @CRLF & 'Return:' & @CRLF & $Ret & @CRLF & @CRLF & '@error:' & @CRLF & @error & @CRLF & @CRLF & '@extended:' & @CRLF & @extended & ' (0x' & Hex(@extended) & ')') ;### Debug MSGBOX

The function returns all 0's, but no entry is made in the registry (HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerPendingFileRenameOperations) [see MS MoveFileEx function], and of course the file isn't deleted after a reboot.

I want to be able to delete a file or directory on the next reboot.  I'm using AutoIt 3.3.10.2.

Any assistance would be appreciated.

Posted

You (or your software) can't write to HKLM yust like that. Add #RequireAdmin at the top of your script and you'll get what you want.

Thanks!  Feel silly!!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...