Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ${SegmentFile}
  2.  
  3. ${SegmentPrePrimary}
  4.     ${If} $UsesRegistry == true
  5.         ${ForEachINIPair} RegistryKeys $0 $1
  6.             ;=== Backup the registry
  7.             ${ValidateRegistryKey} $1
  8.             ${IfNot} ${RegistryKeyExists} HKEY_CURRENT_USER\Software\PortableApps.com\Keys\$1
  9.                 ${If} ${RegistryKeyExists} $1
  10.                     ${DebugMsg} "Backing up registry key $1 to HKEY_CURRENT_USER\Software\PortableApps.com\Keys\$1"
  11.                     ${registry::MoveKey} $1 HKEY_CURRENT_USER\Software\PortableApps.com\Keys\$1 $R9
  12.                     ${If} $R9 != 0 ; -1 = failure (probably HKLM without admin), 0 = success
  13.                         WriteINIStr $DataDirectory\PortableApps.comLauncherRuntimeData-$BaseName.ini FailedRegistryKeys $0 true
  14.                     ${endIf}
  15.                 ${EndIf}
  16.             ${EndIf}
  17.  
  18.             ${If} $0 == -
  19.                 ${DebugMsg} "File name -, not data to import."
  20.             ${ElseIf} ${FileExists} $DataDirectory\settings\$0.reg
  21.                 ${DebugMsg} "Loading $DataDirectory\settings\$0.reg into the registry."
  22.                 ${registry::RestoreKey} $DataDirectory\settings\$0.reg $R9
  23.                 ${If} $R9 != 0 ; -1 = failure (probably HKLM without admin), 0 = success
  24.                     WriteINIStr $DataDirectory\PortableApps.comLauncherRuntimeData-$BaseName.ini FailedRegistryKeys $0 true
  25.                     ${!getdebug}
  26.                     !ifdef DEBUG
  27.                         StrCpy $R9 $1 4
  28.                         ${If} $R9 == HKLM
  29.                         ${AndIf} $RunAsAdmin != force
  30.                             StrCpy $R9 " Note for developers: to always be able to write to HKLM, you will need to set [Launch]:RunAsAdmin to force."
  31.                         ${Else}
  32.                             StrCpy $R9 ""
  33.                         ${EndIf}
  34.                     !endif
  35.                     ${DebugMsg} "Failed to load $DataDirectory\settings\$0.reg into the registry.$R9"
  36.                 ${EndIf}
  37.             ${Else}
  38.                 ${DebugMsg} "File $DataDirectory\settings\$0.reg doesn't exist, not loaded into the registry."
  39.             ${EndIf}
  40.         ${NextINIPair}
  41.     ${EndIf}
  42. !macroend
  43.  
  44. ${SegmentPostPrimary}
  45.     ${If} $UsesRegistry == true
  46.         ${ForEachINIPair} RegistryKeys $0 $1
  47.             ${ValidateRegistryKey} $1
  48.             ${If} $0 == -
  49.                 ${DebugMsg} "Registry key $1 will not be saved."
  50.             ${Else}
  51.                 ClearErrors
  52.                 ReadINIStr $R9 $DataDirectory\PortableApps.comLauncherRuntimeData-$BaseName.ini FailedRegistryKeys $0
  53.                 ${If} ${Errors} ; didn't fail
  54.                 ${AndIf} $RunLocally != true
  55.                     ${DebugMsg} "Saving registry key $1 to $DataDirectory\settings\$0.reg."
  56.                     ${registry::SaveKey} $1 $DataDirectory\settings\$0.reg "" $R9
  57.                 ${EndIf}
  58.             ${EndIf}
  59.  
  60.             ${DebugMsg} "Deleting registry key $1."
  61.             ${registry::DeleteKey} $1 $R9
  62.             ${If} ${RegistryKeyExists} HKEY_CURRENT_USER\Software\PortableApps.com\Keys\$1
  63.                 ${DebugMsg} "Moving registry key HKEY_CURRENT_USER\Software\PortableApps.com\Keys\$1 to $1."
  64.                 ${registry::MoveKey} HKEY_CURRENT_USER\Software\PortableApps.com\Keys\$1 $1 $R9
  65.                 ${Do}
  66.                     ${GetParent} $1 $1
  67.                     ${registry::DeleteKeyEmpty} HKEY_CURRENT_USER\Software\PortableApps.com\Keys\$1 $R9
  68.                 ${LoopUntil} $1 == ""
  69.             ${EndIf}
  70.         ${NextINIPair}
  71.         ${registry::DeleteKeyEmpty} HKEY_CURRENT_USER\Software\PortableApps.com $R9
  72.     ${EndIf}
  73. !macroend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement