Developing a launcher that needs multiple registry keys![]() Submitted by BrianAll on April 3, 2008 - 7:07pm
Okay...
RegistryBackup:
StrCmp $SECONDARYLAUNCH "true" LaunchAndExit
;=== Backup the registry
${registry::KeyExists} "HKEY_CURRENT_USER\Software\7-zip-BackupBy7-ZipPortable" $R0
StrCmp $R0 "0" RestoreTheKey
${registry::KeyExists} "HKEY_CURRENT_USER\Software\7-zip" $R0
StrCmp $R0 "-1" RestoreTheKey
${registry::MoveKey} "HKEY_CURRENT_USER\Software\7-zip" "HKEY_CURRENT_USER\Software\7-zip-BackupBy7-ZipPortable" $R0
Sleep 100
RestoreTheKey:
IfFileExists "$SETTINGSDIRECTORY\7zip_portable.reg" "" LaunchNow
IfFileExists "$WINDIR\system32\reg.exe" "" RestoreTheKey9x
nsExec::ExecToStack `"$WINDIR\system32\reg.exe" import "$SETTINGSDIRECTORY\7zip_portable.reg"`
Pop $R0
StrCmp $R0 '0' LaunchNow ;successfully restored key
RestoreTheKey9x:
${registry::RestoreKey} "$SETTINGSDIRECTORY\7zip_portable.reg" $R0
StrCmp $R0 '0' LaunchNow ;successfully restored key
StrCpy $FAILEDTORESTOREKEY "true"
LaunchNow:
Sleep 100
ExecWait $EXECSTRING
I need to duplicate this for the other keys. Should I just copy it 4 times, or should it be merged together? Can anyone help? ( categories: )
|


Just do doubles of the same....
All you do is make doubles of the same code, if you told me what your registry keys were i could write it 4 you and give you the code. But make sure it is just the main registry key, not all the sub keys within the main one, like the main one from one of my launchers is HKEY_CURRENT_USER\Software\Piriform while it has a sub key that is HKEY_CURRENT_USER\Software\Piriform\Recuva with all this other stuff.
An eye for an eye makes the whole world blind.
Mahatma Gandhi,
Indian political and spiritual leader (1869 - 1948)
heres more to help you
k the launcher i made recently used to main registry keys, HKEY_LOCAL_MACHINE\SOFTWARE\Piriform and HKEY_CURRENT_USER\Software\Piriform, so here is how i added them, please look closley at what was done, cause after you look at this you should be able to do yours, just yours has 2 more keys than mine did. its a bit long so here it is.....oh yeah i also used 7zip source code for the launcher I made.....
RegistryBackup: StrCmp $SECONDARYLAUNCH "true" LaunchAndExit ;=== Backup the registry ${registry::KeyExists} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 StrCmp $R0 "0" RestoreTheKey ${registry::KeyExists} "HKEY_CURRENT_USER\Software\Piriform" $R0 StrCmp $R0 "0" RestoreTheKey ${registry::KeyExists} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 StrCmp $R0 "-1" RestoreTheKey ${registry::KeyExists} "HKEY_CURRENT_USER\Software\Piriform" $R0 StrCmp $R0 "-1" RestoreTheKey ${registry::MoveKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 ${registry::MoveKey} "HKEY_CURRENT_USER\Software\Piriform" "HKEY_CURRENT_USER\Software\Piriform" $R0 Sleep 100 RestoreTheKey: IfFileExists "$SETTINGSDIRECTORY\Defraggler.reg" "" LaunchNow IfFileExists "$WINDIR\system32\reg.exe" "" RestoreTheKey9x nsExec::ExecToStack `"$WINDIR\system32\reg.exe" import "$SETTINGSDIRECTORY\Defraggler.reg"` Pop $R0 StrCmp $R0 '0' LaunchNow ;successfully restored key RestoreTheKey9x: ${registry::RestoreKey} "$SETTINGSDIRECTORY\Defraggler.reg" $R0 StrCmp $R0 '0' LaunchNow ;successfully restored key StrCpy $FAILEDTORESTOREKEY "true"An eye for an eye makes the whole world blind.
Mahatma Gandhi,
Indian political and spiritual leader (1869 - 1948)
Great!
Thanks man, I'll give you some credit in the launcher when I finish it. :)
"It's not a question of where he grips it! It's a simple question of weight ratios! A five ounce bird could not carry a one pound coconut!"
It may be better to keep
It may be better to keep them each seperated, instead of interlocked like that, for example
StrCmp $SECONDARYLAUNCH "true" LaunchAndExit ;=== Backup the registry RegBackup1: ${registry::KeyExists} "HKEY_CURRENT_USER\Software\Piriform" $R0 StrCmp $R0 "0" RegBackup2 ${registry::KeyExists} "HKEY_CURRENT_USER\Software\Piriform" $R0 StrCmp $R0 "-1" RegBackup2 ${registry::MoveKey} "HKEY_CURRENT_USER\Software\Piriform" "HKEY_CURRENT_USER\Software\Piriform" $R0 Sleep 100 RegBackup2: ${registry::KeyExists} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 StrCmp $R0 "0" RestoreTheKey ${registry::KeyExists} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 StrCmp $R0 "-1" RestoreTheKey ${registry::MoveKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 Sleep 100This way, if one set of keys fails, the other can still be processed. The the setup listed above, if the very first condition isn't passed, it jumps right to RestoreTheKey, skipping all other reg keys.
The developer formerly known as ZGitRDun8705
Oh yeah dont forget....
Dont forget to do this afterwards, to make sure it works properly. Take your time as it is easy to forget and make mistakes.Also make sure on SetOriginalKeyBack: you add all your keys to delete and Keyexists or they wont be removed.
LaunchNow: Sleep 100 ExecWait $EXECSTRING CheckRunning: Sleep 1000 FindProcDLL::FindProc "${DEFAULTEXE}" StrCmp $R0 "1" CheckRunning StrCmp $FAILEDTORESTOREKEY "true" SetOriginalKeyBack ${registry::SaveKey} "HKEY_CURRENT_USER\Software\Piriform" "$SETTINGSDIRECTORY\Defraggler.reg" "" $0 ${registry::SaveKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" "$SETTINGSDIRECTORY\Defraggler.reg" "" $0 Sleep 100 SetOriginalKeyBack: ${registry::DeleteKey} "HKEY_CURRENT_USER\Software\Piriform" $R0 ${registry::DeleteKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 Sleep 100 ${registry::KeyExists} "HKEY_CURRENT_USER\Software\Piriform" $R0 StrCmp $R0 "-1" TheEnd ${registry::KeyExists} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 StrCmp $R0 "-1" TheEnd ${registry::MoveKey} "HKEY_CURRENT_USER\Software\Piriform" "HKEY_CURRENT_USER\Software\Piriform" $R0 ${registry::MoveKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" "HKEY_LOCAL_MACHINE\SOFTWARE\Piriform" $R0 Sleep 100 Goto TheEndAn eye for an eye makes the whole world blind.
Mahatma Gandhi,
Indian political and spiritual leader (1869 - 1948)
HKLM is different
HKLM is a special case. Only an admin account can write to it. Check out the Eraser Portable launcher for example code on handling both HKCU and HKLM and checking for account rights.
Live with purpose.
Yeah I know
I'll check out the source for eraser portable asap.
Thanks.
"It's not a question of where he grips it! It's a simple question of weight ratios! A five ounce bird could not carry a one pound coconut!"
Ohh.
I just used what Rab040ma gave me. A macro to check if admin, and if it is, it'll do those reg keys.
Somebody give me a portable video editor... Please!
If ya wanna see my email, go to digitxpsemail.tk (at least for now!)
My dad saved over $850 a month, by switching to Geico! :P