Replace File On Reboot: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(Created page with "== The Script == <highlight-nsis> !define PRODUCT_CODE "MyProductCode" RequestExecutionLevel admin ShowInstDetails show ; The name of the installer Name "ReplaceOnReboot" ; ...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{PageAuthor|shane}} | |||
== Description == | |||
Replace an existing file on reboot. (For replacing files in-use, etc.) | |||
== The Script == | == The Script == | ||
<highlight-nsis> | <highlight-nsis> |
Revision as of 06:23, 19 July 2011
Author: shane (talk, contrib) |
Description
Replace an existing file on reboot. (For replacing files in-use, etc.)
The Script
!define PRODUCT_CODE "MyProductCode" RequestExecutionLevel admin ShowInstDetails show ; The name of the installer Name "ReplaceOnReboot" ; The file to write OutFile "ReplaceOnReboot.exe" ; Get the existing product installation directory - use that for the INSTDIR value InstallDirRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_CODE}" "InstallLocation" Section "" ;No components page, name is not important StrCmp $INSTDIR "" 0 +2 ; If the INSTDIR is empty, we need to abort Abort ;Stage the files in the Windows\Temp directory until the next reboot ;then call MoveFileEx to move them after the next reboot CreateDirectory "$WINDIR\Temp\${PRODUCT_CODE}" SetOutPath "$WINDIR\Temp\${PRODUCT_CODE}" File "test.dll" ;Call MoveFileEx on each file above (Params: <source>, <destination>, 4) 5 == Move on Reboot && Replace Existing System::Call "kernel32::MoveFileEx(t '$WINDIR\Temp\${PRODUCT_CODE}\test.dll', t '$INSTDIR\test.dll', i 5)" SectionEnd ; end the section