0
我的安裝程序將Uninstall.exe和/ temp /目錄複製到安裝文件夾(對於我來說它是C:\ MyExample),但是MyExample.dll/ico/exe ,併成功/ error.wav直接複製到C:\,我不能得到這個工作。文件安裝到C:而不是C:文件夾
!include "MUI2.nsh"
;General
Function .onInit
ReadEnvStr $R0 SYSTEMDRIVE
StrCpy $INSTDIR `$R0\MyExample\`
FunctionEnd
Name "MyExample"
OutFile "Setup.exe"
RequestExecutionLevel admin
;--------------------------------
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
!define MUI_FINISHPAGE_SHOWREADME ""
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION finishpageaction
;--------------------------------
;Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Dummy Section" SecDummy
File "MyExample.exe"
File "MyExample.ico"
File "error.wav"
File "success.wav"
File "MyExample.dll"
CreateDirectory $INSTDIR\temp
SetOutPath "$INSTDIR"
WriteRegStr HKCU "Software\MyExample" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Product\MyExample" \
"MyExample" "$\"$INSTDIR\uninstall.exe$\""
SectionEnd
Section "Uninstall"
# Always delete uninstaller first
delete $INSTDIR\uninstall.exe
delete $INSTDIR\MyExample.exe
delete $INSTDIR\MyExample.ico
delete $INSTDIR\error.wav
delete $INSTDIR\success.wav
delete $INSTDIR\MyExample.dll
SectionEnd
;--------------------------------
;Descriptions
LangString DESC_SecDummy ${LANG_ENGLISH} "Setup"
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\MyExample"
SectionEnd
Function LaunchLink
ExecShell "" "$INSTDIR\MyExample.exe"
FunctionEnd
Function finishpageaction
CreateShortcut "$desktop\MyExample.lnk" "$instdir\MyExample.exe"
WriteRegStr HKEY_CURRENT_USER "Software\Microsoft\Windows\CurrentVersion\Run" \
"MyExample.exe" "$INSTDIR\MyExample.exe"
FunctionEnd