8 Replies Latest reply on Sep 8, 2008 3:47 AM by BISCK

    Using EndInstallerSession command in uninstall script

    BISCK Rookie
      Hi all,

      I hope you can help. I'm a relative newbie to NetInstall. I've built a package for a particular product, the installation works fine and so I turned to the uninstall script as it's not a straightforward uninstall because it's not an MSI installation. I've figured out how to automate the uninstall but this requires a restart in between uninstalling two different components.

      I've written a custom uninstall script as part of the project under the $BeginUninstallScript variable. It has a System_Reset and an EndInstallerSession in between the two different component removal instructions. The problem that I'm having is that NetInstall is completely ignoring the EndInstallerSession command within the uninstall script. I cannot see a "EndUninstallerSession" command so I'm at a loss as to how to make a two part uninstallation, with a restart in between the two instructions, without using the dreaded CallNiProc command to call an custom built uninstallation package in the guise of an install package.

      Any and all help would be much appreciated.
        • 1. Re: Using EndInstallerSession command in uninstall script
          map Specialist

          Hi all,

          I hope you can help. I'm a relative newbie to NetInstall. I've built a package for a particular product, the installation works fine and so I turned to the uninstall script as it's not a straightforward uninstall because it's not an MSI installation. I've figured out how to automate the uninstall but this requires a restart in between uninstalling two different components.

          I've written a custom uninstall script as part of the project under the $BeginUninstallScript variable. It has a System_Reset and an EndInstallerSession in between the two different component removal instructions. The problem that I'm having is that NetInstall is completely ignoring the EndInstallerSession command within the uninstall script. I cannot see a "EndUninstallerSession" command so I'm at a loss as to how to make a two part uninstallation, with a restart in between the two instructions, without using the dreaded CallNiProc command to call an custom built uninstallation package in the guise of an install package.

          Any and all help would be much appreciated.


          This is "works as designed".

          All the NetInstall commands that influence the installers behavior, like
          - EndInstallerSession
          - SystemReset
          etc.

          do *not* work immediately (as in "from the very line of script they are in"), but *after* the script has run *completely*. If you dont jump over lines of code using goto's or IFs, a NetInstall script will always finish to the last line.

          So, a NI-script that has the "EndInstallerSession" in the first line will behave identical to one that has it in the last line.

          You *could* achieve what you want by adding an IF statement and a goto and an :end label. But then, you would be running into the next issue, which is:

          By default, NetInstall won't install the same package twice, before and after the reboot, because after finishing it first time it will be recorded as "successfully installed". There are ways around this but these require messing around with more markers,labels, gotos etc. which would make that script very clumsy and hard to maintain.

          Inside an uninstall situation that is even more complicated, because the program will be *deregistered* on the client after the first run.... so my advice would be:

          If you need "do something, reboot, do next thing" inside an uninstall, i'd create a separate uninstall script split it in two different packages with the second one's permissions or conditions set in a way so that it only will run after the first has been run.

          Martin
          • 2. Re: Using EndInstallerSession command in uninstall script
            BISCK Rookie
            Ok, thanks for your advice. I'll have to use the CallNiProc command under the $BeginUninstallScript label to call an umbrella project for two different uninstall packages in that case.
            • 3. Re: Using EndInstallerSession command in uninstall script
              map Specialist
              I hesitate to say "that will work" because i haven't tested it yet, but i think that is the way to go!
              • 4. Re: Using EndInstallerSession command in uninstall script
                NicoS1 Master
                An If clause works.

                Just for example:

                => If exist (C:\Program1\program1.exe)
                ==>Uninstall stuff.
                ==>Exitproc(undone)
                ==>System_Reset
                => Else
                ==>Uninstall program2

                What will happen? If a User uninstalls a software the package will first uninstall Program one, due to exitproc undone, the policy will stay unsuccessful and the system will reboot. After the Reboot, the Autoinstaller notices the unsuccessfull policy and trys to complete it. This time, he does not jump into the IF part, but in the else part, uninstall the 2nd Software and complete as successfull.
                • 5. Re: Using EndInstallerSession command in uninstall script
                  BISCK Rookie
                  Ah, that's much more tidy. Will that work if under the $BeginUninstallScript tag though?

                  EDIT: I've just tried this under the $BeginUninstallScript and although it does jump out of the uninstallation at the correct time, it doesn't subsequently re-run the uninstall script after rebooting, which would lead to the second component being uninstalled. If you click Uninstall again though, then it completes the uninstallation successfully. It's not ideal, but it's an improvement on before.
                  • 6. Re: Using EndInstallerSession command in uninstall script
                    BISCK Rookie
                    In the end I resolved this by using the method below:


                    :$BeginUninstallscript
                    If Exist(%files from first component to be removed%)
                      %Uninstall script for first component to be removed%
                      RegModify('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce','NiUninstKey','niinst32.exe /execute:{GUID of project} /uninstall'
                      System_Reset
                      ExitProc(Undone)
                    Else
                      Uninstall script for second component to be removed
                    • 7. Re: Using EndInstallerSession command in uninstall script
                      Mark107 Rookie
                      couldn't you just make two seperate scripts and set the one as a component of the other, with a reboot in between?
                      • 8. Re: Using EndInstallerSession command in uninstall script
                        BISCK Rookie
                        No, as these commands are for uninstallation, not installation. Plus I wanted to keep it tidy all within the same script, rather than having to worry about extra permissions etc just for an "split uninstallation" package.