Advertisement
Guest User

Untitled

a guest
Jan 28th, 2011
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Age of Empires II - The Age of Kings (Portable Edition)
  2. ;by [#Ph4n70m]
  3.  
  4. Name "AoE2KingsPortable"
  5. SilentInstall silent
  6. ShowInstDetails nevershow
  7. OutFile "..\TheKings.exe"
  8. Icon "TheKings.ico"
  9. VIProductVersion "1.0.0.0"
  10. VIAddVersionKey FileVersion "1.0.0.0"
  11. VIAddVersionKey FileDescription "Age of Empires II - The Age of Kings for portable devices."
  12. VIAddVersionKey LegalCopyright "[#Ph4n70m]"
  13. VIAddVersionKey ProductName "Age of Empires II - The Age of Kings (Portable Edition)"
  14. VIAddVersionKey CompanyName "[#Ph4n70m]"
  15.  
  16. !define HKLMREGKEY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Age of Empires\2.0"
  17. !define HKCUREGKEY "HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires\2.0"
  18.  
  19. !include Registry.nsh
  20.  
  21. Var APPDIR
  22. Var DEFAULTDATADIR
  23. Var DATADIR
  24.  
  25.  
  26. Section "Main"
  27.  Call SetVariables
  28.  Call PrepareHost
  29.  Call StartApplication
  30.  Call CleanHost
  31. SectionEnd
  32.  
  33. Function SetVariables
  34.  StrCpy $APPDIR "$EXEDIR\App\AoE2"
  35.  StrCpy $DEFAULTDATADIR "$EXEDIR\App\DefaultData"
  36.  StrCpy $DATADIR "$EXEDIR\Data"
  37. FunctionEnd
  38.  
  39. Function PrepareHost
  40.   SetOutPath "$APPDIR"
  41.   ${registry::KeyExists} "${HKLMREGKEY}" $0
  42.   StrCmp $0 "-1" ContinueWithoutBackupHKLM
  43.   ${registry::MoveKey} "${HKLMREGKEY}" "${HKLMREGKEY} HostBackup" $0
  44.  ContinueWithoutBackupHKLM:
  45.   ${registry::KeyExists} "${HKCUREGKEY}" $0
  46.   StrCmp $0 "-1" ContinueWithoutBackupHKCU
  47.   ${registry::MoveKey} "${HKCUREGKEY}" "${HKCUREGKEY} HostBackup" $0
  48.  ContinueWithoutBackupHKCU:
  49.   IfFileExists "$DATADIR\TheKings_HKLM_Registry.reg" ImportHKLM
  50.   CopyFiles /SILENT "$DEFAULTDATADIR\TheKings_HKLM_Default.reg" "$DATADIR\TheKings_HKLM_Registry.reg"
  51.  ImportHKLM:
  52.   nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\TheKings_HKLM_Registry.reg"`
  53.   IfFileExists "$DATADIR\TheKings_HKCU_Registry.reg" ImportHKCU
  54.   CopyFiles /SILENT "$DEFAULTDATADIR\TheKings_HKCU_Default.reg" "$DATADIR\TheKings_HKCU_Registry.reg"
  55.  ImportHKCU:
  56.   nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\TheKings_HKCU_Registry.reg"`
  57.   ${registry::Write} "${HKLMREGKEY}" "EXE Path" "$APPDIR" "REG_SZ" $0
  58.   ${registry::Write} "${HKLMREGKEY}" "InstallationDirectory" "$APPDIR" "REG_SZ" $0
  59. FunctionEnd
  60.  
  61. Function StartApplication
  62.  ExecWait "$APPDIR\empires2.exe"
  63. FunctionEnd
  64.  
  65. Function CleanHost
  66.   ${registry::SaveKey} "${HKLMREGKEY}" "$DATADIR\TheKings_HKLM_Registry.reg" "" $0
  67.   ${registry::SaveKey} "${HKCUREGKEY}" "$DATADIR\TheKings_HKCU_Registry.reg" "" $0
  68.   ${registry::DeleteKey} "${HKLMREGKEY}" $0
  69.   ${registry::DeleteKey} "${HKCUREGKEY}" $0
  70.   ${registry::KeyExists} "${HKLMREGKEY} HostBackup" $0
  71.   StrCmp $0 "-1" ContinueWithoutRestoreHKLM
  72.   ${registry::MoveKey} "${HKLMREGKEY} HostBackup" "${HKLMREGKEY}" $0
  73.  ContinueWithoutRestoreHKLM:
  74.   ${registry::KeyExists} "${HKCUREGKEY} HostBackup" $0
  75.   StrCmp $0 "-1" ContinueWithoutRestoreHKCU
  76.   ${registry::MoveKey} "${HKCUREGKEY} HostBackup" "${HKCUREGKEY}" $0
  77.  ContinueWithoutRestoreHKCU:
  78.   ${registry::Unload}
  79.   DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Microsoft Games\Age of Empires"
  80.   DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Microsoft Games"
  81.   DeleteRegKey /ifempty HKCU "Software\Microsoft\Microsoft Games\Age of Empires"
  82.   DeleteRegKey /ifempty HKCU "Software\Microsoft\Microsoft Games"
  83. FunctionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement