Advertisement
Guest User

Untitled

a guest
Jan 28th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Age of Empires (Portable Edition)
  2. ;by [#Ph4n70m]
  3.  
  4. Name "AoEPortable"
  5. SilentInstall silent
  6. ShowInstDetails nevershow
  7. OutFile "..\AgeOfEmpires.exe"
  8. Icon "AgeOfEmpires.ico"
  9. VIProductVersion "1.0.0.0"
  10. VIAddVersionKey FileVersion "1.0.0.0"
  11. VIAddVersionKey FileDescription "Age of Empires for portable devices."
  12. VIAddVersionKey LegalCopyright "[#Ph4n70m]"
  13. VIAddVersionKey ProductName "Age of Empires (Portable Edition)"
  14. VIAddVersionKey CompanyName "[#Ph4n70m]"
  15.  
  16. !define HKLMREGKEY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Games\Age of Empires\1.00"
  17. !define HKCUREGKEY "HKEY_CURRENT_USER\Software\Microsoft\Games\Age of Empires\1.00"
  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\AoE"
  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\AgeOfEmpires_HKLM_Registry.reg" ImportHKLM
  50.   CopyFiles /SILENT "$DEFAULTDATADIR\AgeOfEmpires_HKLM_Default.reg" "$DATADIR\AgeOfEmpires_HKLM_Registry.reg"
  51.  ImportHKLM:
  52.   nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\AgeOfEmpires_HKLM_Registry.reg"`
  53.   IfFileExists "$DATADIR\AgeOfEmpires_HKCU_Registry.reg" ImportHKCU
  54.   CopyFiles /SILENT "$DEFAULTDATADIR\AgeOfEmpires_HKCU_Default.reg" "$DATADIR\AgeOfEmpires_HKCU_Registry.reg"
  55.  ImportHKCU:
  56.   nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\AgeOfEmpires_HKCU_Registry.reg"`
  57.   ${registry::Write} "${HKLMREGKEY}" "InstallationDirectory" "$APPDIR" "REG_SZ" $0
  58. FunctionEnd
  59.  
  60. Function StartApplication
  61.  ExecWait "$APPDIR\Empires.exe"
  62. FunctionEnd
  63.  
  64. Function CleanHost
  65.   ${registry::SaveKey} "${HKLMREGKEY}" "$DATADIR\AgeOfEmpires_HKLM_Registry.reg" "" $0
  66.   ${registry::SaveKey} "${HKCUREGKEY}" "$DATADIR\AgeOfEmpires_HKCU_Registry.reg" "" $0
  67.   ${registry::DeleteKey} "${HKLMREGKEY}" $0
  68.   ${registry::DeleteKey} "${HKCUREGKEY}" $0
  69.   ${registry::KeyExists} "${HKLMREGKEY} HostBackup" $0
  70.   StrCmp $0 "-1" ContinueWithoutRestoreHKLM
  71.   ${registry::MoveKey} "${HKLMREGKEY} HostBackup" "${HKLMREGKEY}" $0
  72.  ContinueWithoutRestoreHKLM:
  73.   ${registry::KeyExists} "${HKCUREGKEY} HostBackup" $0
  74.   StrCmp $0 "-1" ContinueWithoutRestoreHKCU
  75.   ${registry::MoveKey} "${HKCUREGKEY} HostBackup" "${HKCUREGKEY}" $0
  76.  ContinueWithoutRestoreHKCU:
  77.   ${registry::Unload}
  78.   DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Games\Age of Empires"
  79.   DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Games"
  80.   DeleteRegKey /ifempty HKCU "Software\Microsoft\Games\Age of Empires"
  81.   DeleteRegKey /ifempty HKCU "Software\Microsoft\Games"
  82. FunctionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement