ChrisL Posted September 30, 2006 Posted September 30, 2006 This little udf will make windows copy used or locked files after the PC is rebooted. Copy the new files to a temporary location and call the function with the new file full path and the file to replace full path. You can call this multiple times to add more files to the restart copy list in the registry. _CopyAfterRestart("c:\temp\myfile.exe","C:\Documents and Settings\ChrisLambert\Desktop\myFile.exe") expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.2.* ; Author: Chris Lambert ; ; Script Function: ; Template AutoIt script. ; ; ---------------------------------------------------------------------------- ;=============================================================================== ; ;~ Function: _CopyAfterRestart() ;~ Desctiption tells windows to copy files on reboot ;~ Version: N/A ;~ Author: ChrisL ;~ Parameter(s): ;~ $new_file = The full path to the new file to use after reboot ;~ $to_replace = The full path to the old file to overwrite ;~ Example: ;~ _CopyAfterRestart("c:\temp\internet.exe","C:\Documents and Settings\ChrisLambert\Desktop\internet.exe") ;~ _CopyAfterRestart("c:\temp\myfile.exe","C:\Documents and Settings\ChrisLambert\Desktop\myFile.exe") ;~ @error 1 $new_file does not exist ;~ @error 2 $to_replace does not exist ; ;=============================================================================== Func _CopyAfterRestart($new_file,$to_replace) If NOT FileExists($new_file) then SetError(1) Return 0 EndIf If NOT FileExists($to_replace) then SetError(2) Return 0 EndIf $existing_entries = Regread ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager","PendingFileRenameOperations") If $existing_entries <> "" then $existing_entries = $existing_entries & @lf Regwrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager","PendingFileRenameOperations","REG_MULTI_SZ",$existing_entries & "\??\" & $new_file & @lf & "!\??\" & $to_replace) Endfunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now