Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Age of Empires II - The Age of Kings (Portable Edition)
- ;by [#Ph4n70m]
- Name "AoE2KingsPortable"
- SilentInstall silent
- ShowInstDetails nevershow
- OutFile "..\TheKings.exe"
- Icon "TheKings.ico"
- VIProductVersion "1.0.0.0"
- VIAddVersionKey FileVersion "1.0.0.0"
- VIAddVersionKey FileDescription "Age of Empires II - The Age of Kings for portable devices."
- VIAddVersionKey LegalCopyright "[#Ph4n70m]"
- VIAddVersionKey ProductName "Age of Empires II - The Age of Kings (Portable Edition)"
- VIAddVersionKey CompanyName "[#Ph4n70m]"
- !define HKLMREGKEY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Age of Empires\2.0"
- !define HKCUREGKEY "HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires\2.0"
- !include Registry.nsh
- Var APPDIR
- Var DEFAULTDATADIR
- Var DATADIR
- Section "Main"
- Call SetVariables
- Call PrepareHost
- Call StartApplication
- Call CleanHost
- SectionEnd
- Function SetVariables
- StrCpy $APPDIR "$EXEDIR\App\AoE2"
- StrCpy $DEFAULTDATADIR "$EXEDIR\App\DefaultData"
- StrCpy $DATADIR "$EXEDIR\Data"
- FunctionEnd
- Function PrepareHost
- SetOutPath "$APPDIR"
- ${registry::KeyExists} "${HKLMREGKEY}" $0
- StrCmp $0 "-1" ContinueWithoutBackupHKLM
- ${registry::MoveKey} "${HKLMREGKEY}" "${HKLMREGKEY} HostBackup" $0
- ContinueWithoutBackupHKLM:
- ${registry::KeyExists} "${HKCUREGKEY}" $0
- StrCmp $0 "-1" ContinueWithoutBackupHKCU
- ${registry::MoveKey} "${HKCUREGKEY}" "${HKCUREGKEY} HostBackup" $0
- ContinueWithoutBackupHKCU:
- IfFileExists "$DATADIR\TheKings_HKLM_Registry.reg" ImportHKLM
- CopyFiles /SILENT "$DEFAULTDATADIR\TheKings_HKLM_Default.reg" "$DATADIR\TheKings_HKLM_Registry.reg"
- ImportHKLM:
- nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\TheKings_HKLM_Registry.reg"`
- IfFileExists "$DATADIR\TheKings_HKCU_Registry.reg" ImportHKCU
- CopyFiles /SILENT "$DEFAULTDATADIR\TheKings_HKCU_Default.reg" "$DATADIR\TheKings_HKCU_Registry.reg"
- ImportHKCU:
- nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\TheKings_HKCU_Registry.reg"`
- ${registry::Write} "${HKLMREGKEY}" "EXE Path" "$APPDIR" "REG_SZ" $0
- ${registry::Write} "${HKLMREGKEY}" "InstallationDirectory" "$APPDIR" "REG_SZ" $0
- FunctionEnd
- Function StartApplication
- ExecWait "$APPDIR\empires2.exe"
- FunctionEnd
- Function CleanHost
- ${registry::SaveKey} "${HKLMREGKEY}" "$DATADIR\TheKings_HKLM_Registry.reg" "" $0
- ${registry::SaveKey} "${HKCUREGKEY}" "$DATADIR\TheKings_HKCU_Registry.reg" "" $0
- ${registry::DeleteKey} "${HKLMREGKEY}" $0
- ${registry::DeleteKey} "${HKCUREGKEY}" $0
- ${registry::KeyExists} "${HKLMREGKEY} HostBackup" $0
- StrCmp $0 "-1" ContinueWithoutRestoreHKLM
- ${registry::MoveKey} "${HKLMREGKEY} HostBackup" "${HKLMREGKEY}" $0
- ContinueWithoutRestoreHKLM:
- ${registry::KeyExists} "${HKCUREGKEY} HostBackup" $0
- StrCmp $0 "-1" ContinueWithoutRestoreHKCU
- ${registry::MoveKey} "${HKCUREGKEY} HostBackup" "${HKCUREGKEY}" $0
- ContinueWithoutRestoreHKCU:
- ${registry::Unload}
- DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Microsoft Games\Age of Empires"
- DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Microsoft Games"
- DeleteRegKey /ifempty HKCU "Software\Microsoft\Microsoft Games\Age of Empires"
- DeleteRegKey /ifempty HKCU "Software\Microsoft\Microsoft Games"
- FunctionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement