PDA

View Full Version : Where does SB actually commit the uninstall registry entry?



NewsArchive
03-25-2010, 02:10 AM
Our installer generates a new GUID each time your do an install. This
was done so that if you install into a different directory on you hard
drive, it gets a new 'uninstaller' entry in the control panel.

I've written some logic that loops through all the keys of the uninstall
branch and returns the InstallLocation. If we find the same location
that was chosen this time, we grab the GUID for that install and I
update the %MYGUID% variable with the 'Found' GUID, however, I can't
seem to find where the correct place to place this code.

At what point is the installer writing the registry info and where is a
good place to put this type of code?

Thanks,
Ken

NewsArchive
03-25-2010, 02:10 AM
Hi Ken,

> Our installer generates a new GUID each time your do an install. This was
> done so that if you install into a different directory on you hard drive,
> it gets a new 'uninstaller' entry in the control panel.
>
> I've written some logic that loops through all the keys of the uninstall
> branch and returns the InstallLocation. If we find the same location that
> was chosen this time, we grab the GUID for that install and I update the
> %MYGUID% variable with the 'Found' GUID, however, I can't seem to find
> where the correct place to place this code.
>
> At what point is the installer writing the registry info and where is a
> good place to put this type of code?

The following function in your script creates the uninstall .exe, .log, and
uninstall entries:

Create Installation App & Log "[UNINSTALL_LOG]"

In Windows, the uninstall information is stored under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\CurrentVersi on\Uninstall.

Friedrich

NewsArchive
03-27-2010, 04:12 AM
Thanks Friedrich,

I have the following code just above the 'Create Installation...' line,
however, it still places a new registry key for the installation, even
though it is going into the same directory, does anyone see or know of
any issues with this.

-----------------------------------------------------------------------

! We need to loop through all the UNINSTALL keys in the registry and see
if any of them
! have a the same installation path as the one chosen for this install.
If so, we need to
! get the GUID for that install and use it instead of generating a new one.

! Initialize Subkey scan. The %SUBKEYS% variable holds the number of
found key items.
Set Variable %SUBKEYS% to FUNCTION:Get Registry SubKey("0") from
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall"
! Initialize LOOPID variable
Set Variable %LOOPID% to "0"
! Make a copy of the install directory and lower it
Set Variable %_PB_TEMPINSTALL% to "%_SB_INSTALLDIR%"
Set Variable %_PB_TEMPINSTALL% to FUNCTION:Lower(%_PB_TEMPINSTALL%)
! Loop through all subkeys
Loop (%SUBKEYS% Times)
Set Variable %LOOPID% to (Increment Variable by 1)
! Retrieve next subkey
Set Variable %SUBKEY_RESULT% to FUNCTION:Get Registry
SubKey("%LOOPID%") from
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall"

Set Variable %EXISTING_INSTALL_PATH% to FUNCTION:Get Registry Key
Value("InstallLocation") from
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall\%SUBKEY_RESULT%"
Set Variable %LOWERED_EXISTING_INSTALL_PATH% to
FUNCTION:Lower(%EXISTING_INSTALL_PATH%)
/* Display Message Box "Key = %SUBKEY_RESULT%\nIntallPath=
%LOWERED_EXISTI..." -- "Install Path" */
If %EXISTING_INSTALL_PATH% Equals "%_PB_TEMPINSTALL%" Then
! Assign the original GUID to our currrent install GUID
Display Message Box "MYGUID = %MYGUID%\nSUBKEY = %SUBKEY_RESULT%"
-- "GUID"
Set Variable %MYGUID% to "%SUBKEY_RESULT%"
#set compiler variable [PRODUCTGUID] = "%MYGUID%"
Break Loop
End
End


-----------------------------------------------------------------------

Thanks,
Ken

NewsArchive
03-27-2010, 04:13 AM
Ken,

I think there is a problem in your script logic. As I understand it, you
mix compile time and runtime elements.

For example, you have the following in the runtime LOOP:

#set compiler variable [PRODUCTGUID] = "%MYGUID%"

The above line is a compiler directive (only executed at script COMPILE
time). But you are using it in your Loop statement (executed at installer
RUN time).

I think what you are trying to do is to set a compiler variable
[PRODUCTGUID] to %MYGUID% in your Loop at runtime, right? But from the
technical point of view, this is impossible. #set compiler variable is
executed if you compile the script, not if you run your setup.exe.

You have to modify your script logic to achieve what you want.

Does this help?

Friedrich

NewsArchive
03-27-2010, 04:14 AM
Hi Friedrich,

Let me make sure I understand this; I've commented out the compiler
directive, however at the beginning of my script I have that same line;

#set compiler variable [PRODUCTGUID] = "%MYGUID%

Am I correct in saying that I can change the %MYGUID% variable any where
in the code as long as it is before the info is written to the registry?

If that is the case then the line that says

Set Variable %MYGUID% to "%SUBKEY_RESULT%" should do the trick but it
doesn't appear to be working which I'm guessing is because I'm
completely missing something.

And as always Thanks for the help!

Cheers!
Ken

NewsArchive
03-27-2010, 04:14 AM
Ken,

Compiler directives are executed on the developer's machine.
Other script elements are executed on the end-user's machine.

Compiler variables are used during the compile process to create your
package and are evaluated when you compile the script.
Runtime variables are evaluated when the end-user runs the installer on his
machine.

At compile time, you are trying to set a compiler variable to the contents
of a runtime variable.
If you insert a #msgbox compiler directive to display that, I think you'll
see that your compiler variable is being set to
%MYGUID%
not to the CONTENTS of %MYGUID%

Jane

NewsArchive
03-27-2010, 04:16 AM
Hi Ken,

> Set Variable %MYGUID% to "%SUBKEY_RESULT%" should do the trick but it
> doesn't appear to be working which I'm guessing is because I'm completely
> missing something.
>
> And as always Thanks for the help!

We are also using the method of "multiple GUIDs" in our own LSZip install.
One setup.exe can install different products with different Product GUIDs.

http://www.lindersoft.com/forums/showthread.php?t=7469

Do the following:

1. Set the [PRODUCTGUID] in your "General Information" (you can also set it
in the "Compiler Variables Visualizer") to a runtime variable, say,
%MY_PRODUCTGUID%.

2. In your script, just set %MY_PRODUCTGUID% and you are done.

Does this help?

Friedrich

NewsArchive
03-27-2010, 04:17 AM
>
> 2. In your script, just set %MY_PRODUCTGUID% and you are done.
>

BTW, you have to do the above BEFORE your call to:

Create Installation App & Log "[UNINSTALL_LOG]"

Friedrich

NewsArchive
03-27-2010, 04:17 AM
Thanks folks, its working like a champ!

Cheers!
ken