Advertisement
Guest User

Untitled

a guest
Jan 28th, 2011
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Age of Empires II - The Conquerors Expansion (Portable Edition)
  2. ;by [#Ph4n70m]
  3.  
  4. Name "AoE2ConquerorsPortable"
  5. SilentInstall silent
  6. ShowInstDetails nevershow
  7. OutFile "..\TheConquerors.exe"
  8. Icon "TheConquerors.ico"
  9. VIProductVersion "1.0.0.0"
  10. VIAddVersionKey FileVersion "1.0.0.0"
  11. VIAddVersionKey FileDescription "Age of Empires II - The Conquerors Expansion for portable devices."
  12. VIAddVersionKey LegalCopyright "[#Ph4n70m]"
  13. VIAddVersionKey ProductName "Age of Empires II - The Conquerors Expansion (Portable Edition)"
  14. VIAddVersionKey CompanyName "[#Ph4n70m]"
  15.  
  16. !define KINGSHKLMREGKEY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Age of Empires\2.0"
  17. !define KINGSHKCUREGKEY "HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires\2.0"
  18. !define CONQHKLMREGKEY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Age of Empires II: The Conquerors Expansion\1.0"
  19. !define CONQHKCUREGKEY "HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires II: The Conquerors Expansion\1.0"
  20.  
  21. !include Registry.nsh
  22.  
  23. Var APPDIR
  24. Var DEFAULTDATADIR
  25. Var DATADIR
  26.  
  27.  
  28. Section "Main"
  29.  Call SetVariables
  30.  Call PrepareHost
  31.  Call StartApplication
  32.  Call CleanHost
  33. SectionEnd
  34.  
  35. Function SetVariables
  36.  StrCpy $APPDIR "$EXEDIR\App\AoE2"
  37.  StrCpy $DEFAULTDATADIR "$EXEDIR\App\DefaultData"
  38.  StrCpy $DATADIR "$EXEDIR\Data"
  39. FunctionEnd
  40.  
  41. Function PrepareHost
  42.  ; The Age of Kings part
  43.   SetOutPath "$APPDIR"
  44.   ${registry::KeyExists} "${KINGSHKLMREGKEY}" $0
  45.   StrCmp $0 "-1" ContinueWithoutBackupKingsHKLM
  46.   ${registry::MoveKey} "${KINGSHKLMREGKEY}" "${KINGSHKLMREGKEY} HostBackup" $0
  47.  ContinueWithoutBackupKingsHKLM:
  48.   ${registry::KeyExists} "${KINGSHKCUREGKEY}" $0
  49.   StrCmp $0 "-1" ContinueWithoutBackupKingsHKCU
  50.   ${registry::MoveKey} "${KINGSHKCUREGKEY}" "${KINGSHKCUREGKEY} HostBackup" $0
  51.  ContinueWithoutBackupKingsHKCU:
  52.   IfFileExists "$DATADIR\TheKings_HKLM_Registry.reg" ImportKingsHKLM
  53.   CopyFiles /SILENT "$DEFAULTDATADIR\TheKings_HKLM_Default.reg" "$DATADIR\TheKings_HKLM_Registry.reg"
  54.  ImportKingsHKLM:
  55.   nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\TheKings_HKLM_Registry.reg"`
  56.   IfFileExists "$DATADIR\TheKings_HKCU_Registry.reg" ImportKingsHKCU
  57.   CopyFiles /SILENT "$DEFAULTDATADIR\TheKings_HKCU_Default.reg" "$DATADIR\TheKings_HKCU_Registry.reg"
  58.  ImportKingsHKCU:
  59.   nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\TheKings_HKCU_Registry.reg"`
  60.   ${registry::Write} "${KINGSHKLMREGKEY}" "EXE Path" "$APPDIR" "REG_SZ" $0
  61.   ${registry::Write} "${KINGSHKLMREGKEY}" "InstallationDirectory" "$APPDIR" "REG_SZ" $0
  62.  
  63.  ; The Conquerors part
  64.   ${registry::KeyExists} "${CONQHKLMREGKEY}" $0
  65.   StrCmp $0 "-1" ContinueWithoutBackupConqHKLM
  66.   ${registry::MoveKey} "${CONQHKLMREGKEY}" "${CONQHKLMREGKEY} HostBackup" $0
  67.  ContinueWithoutBackupConqHKLM:
  68.   ${registry::KeyExists} "${CONQHKCUREGKEY}" $0
  69.   StrCmp $0 "-1" ContinueWithoutBackupConqHKCU
  70.   ${registry::MoveKey} "${CONQHKCUREGKEY}" "${CONQHKCUREGKEY} HostBackup" $0
  71.  ContinueWithoutBackupConqHKCU:
  72.   IfFileExists "$DATADIR\TheConquerors_HKLM_Registry.reg" ImportConqHKLM
  73.   CopyFiles /SILENT "$DEFAULTDATADIR\TheConquerors_HKLM_Default.reg" "$DATADIR\TheConquerors_HKLM_Registry.reg"
  74.  ImportConqHKLM:
  75.   nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\TheConquerors_HKLM_Registry.reg"`
  76.   IfFileExists "$DATADIR\TheConquerors_HKCU_Registry.reg" ImportConqHKCU
  77.   CopyFiles /SILENT "$DEFAULTDATADIR\TheConquerors_HKCU_Default.reg" "$DATADIR\TheConquerors_HKCU_Registry.reg"
  78.  ImportConqHKCU:
  79.   nsExec::Exec `"$WINDIR\system32\reg.exe" import "$DATADIR\TheConquerors_HKCU_Registry.reg"`
  80.   ${registry::Write} "${CONQHKLMREGKEY}" "EXE Path" "$APPDIR" "REG_SZ" $0
  81. FunctionEnd
  82.  
  83. Function StartApplication
  84.  ExecWait "$APPDIR\age2_x1\age2_x1.exe"
  85. FunctionEnd
  86.  
  87. Function CleanHost
  88.  ; The Age of Kings part
  89.   ${registry::SaveKey} "${KINGSHKLMREGKEY}" "$DATADIR\TheKings_HKLM_Registry.reg" "" $0
  90.   ${registry::SaveKey} "${KINGSHKCUREGKEY}" "$DATADIR\TheKings_HKCU_Registry.reg" "" $0
  91.   ${registry::DeleteKey} "${KINGSHKLMREGKEY}" $0
  92.   ${registry::DeleteKey} "${KINGSHKCUREGKEY}" $0
  93.   ${registry::KeyExists} "${KINGSHKLMREGKEY} HostBackup" $0
  94.   StrCmp $0 "-1" ContinueWithoutRestoreKingsHKLM
  95.   ${registry::MoveKey} "${KINGSHKLMREGKEY} HostBackup" "${KINGSHKLMREGKEY}" $0
  96.  ContinueWithoutRestoreKingsHKLM:
  97.   ${registry::KeyExists} "${KINGSHKCUREGKEY} HostBackup" $0
  98.   StrCmp $0 "-1" ContinueWithoutRestoreKingsHKCU
  99.   ${registry::MoveKey} "${KINGSHKCUREGKEY} HostBackup" "${KINGSHKCUREGKEY}" $0
  100.  ContinueWithoutRestoreKingsHKCU:
  101.   DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Microsoft Games\Age of Empires"
  102.   DeleteRegKey /ifempty HKCU "Software\Microsoft\Microsoft Games\Age of Empires"
  103.  
  104.  ; The Conquerors part
  105.   ${registry::SaveKey} "${CONQHKLMREGKEY}" "$DATADIR\TheConquerors_HKLM_Registry.reg" "" $0
  106.   ${registry::SaveKey} "${CONQHKCUREGKEY}" "$DATADIR\TheConquerors_HKCU_Registry.reg" "" $0
  107.   ${registry::DeleteKey} "${CONQHKLMREGKEY}" $0
  108.   ${registry::DeleteKey} "${CONQHKCUREGKEY}" $0
  109.   ${registry::KeyExists} "${CONQHKLMREGKEY} HostBackup" $0
  110.   StrCmp $0 "-1" ContinueWithoutRestoreConqHKLM
  111.   ${registry::MoveKey} "${CONQHKLMREGKEY} HostBackup" "${CONQHKLMREGKEY}" $0
  112.  ContinueWithoutRestoreConqHKLM:
  113.   ${registry::KeyExists} "${CONQHKCUREGKEY} HostBackup" $0
  114.   StrCmp $0 "-1" ContinueWithoutRestoreConqHKCU
  115.   ${registry::MoveKey} "${CONQHKCUREGKEY} HostBackup" "${CONQHKCUREGKEY}" $0
  116.  ContinueWithoutRestoreConqHKCU:
  117.   ${registry::Unload}
  118.   DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Microsoft Games\Age of Empires II: The Conquerors Expansion"
  119.   DeleteRegKey /ifempty HKLM "SOFTWARE\Microsoft\Microsoft Games"
  120.   DeleteRegKey /ifempty HKCU "Software\Microsoft\Microsoft Games\Age of Empires II: The Conquerors Expansion"
  121.   DeleteRegKey /ifempty HKCU "Software\Microsoft\Microsoft Games"
  122. FunctionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement