Install does not continue after reboot

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Austin71
    Junior Member
    • Jan 2014
    • 7

    Install does not continue after reboot

    I have written an installer script which checks to be sure the user has admin privileges before doing anything. If the user has admin rights, the script then checks whether a previous version of my app exists. If one exists, the previous version is removed, an executable installer for the new version is copied to a temp directory, and a 'RunOnce' registry key is set. Then the system is rebooted. Installation of the new version continues when the OS encounters the RunOnce key after the reboot. This all works fine.

    However, if the user does not have admin privileges AND the UAC controls are set up at a restrictive level, then the OS interrupts this process. Example: 'Joe User' (not an admin) starts the installer. Before my own check to determine whether Joe User has admin rights, the OS interrupts with a UAC dialog requesting credentials from someone with admin rights (say, 'John Admin'). If they are supplied, then the install proceeds normally, up to and including the reboot. However, after rebooting, Joe User logs back on. The installation will not continue because the 'RunOnce' key was written into the registry for 'John Admin'. If 'John Admin' does happen to log on at any subsequent time, the installation will continue.

    How do I keep this from happening?

    Thanks!
  • jpderuiter
    Major Dude
    • Feb 2007
    • 672

    #2
    Use HKLM instead of HKCU.

    Comment

    • Austin71
      Junior Member
      • Jan 2014
      • 7

      #3
      I am currently writing to:

      HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce

      I think it should work regardless of who logs in, but it doesn't seem to. If 'Joe User' logs in after the reboot, nothing happens. If I subsequently do a "switch user" to 'John Admin', it fires off the RunOnce key as soon as John Admin logs on.

      Comment

      • jpderuiter
        Major Dude
        • Feb 2007
        • 672

        #4
        Do you copy the installer to a user dependent temp folder maybe?

        Comment

        • Austin71
          Junior Member
          • Jan 2014
          • 7

          #5
          That is excellent, I didn't think about that.

          I create a folder under the "$TEMP" directory and put it there, like this:

          StrCpy $TempPath "$TEMP\MyAppName"
          CreateDirectory $TempPath
          SetOutPath $TempPath
          File "c:\InstallerExecutable.exe"


          The documentation says that $TEMP will most likely point to "C:\Windows\Temp" but I tested it, and the above script creates this folder:

          "C:\Users\John Admin\AppData\Local\Temp\MyAppName".

          So this does appear to go to a user dependent Temp folder. Can you suggest a better place for this to go?

          Comment

          • Austin71
            Junior Member
            • Jan 2014
            • 7

            #6
            I tried something that I thought might work, but it failed. Instead of writing the executable to a subdirectory of $TEMP, I created a folder under $APPDATA\Temp, then changed that folder's permissions, like this:

            SetShellVarContext all
            StrCpy $TempPath "$APPDATA\Temp\MyAppName"
            CreateDirectory $TempPath
            AccessControl::GrantOnFile "$TempPath" "Everyone" "GenericRead + GenericExecute + Delete"
            SetOutPath $TempPath
            File "c:\InstallerExecutable.exe"


            With UAC controls set high, I logged in as Joe User. UAC quickly requested admin credentials, so I supplied John Admin. The installation went OK until after the reboot. Upon rebooting, I logged in again as Joe User (as Joe User might do). The RunOnce key was set correctly in HKLM, and the executable was waiting to be run in $APPDATA\Temp\MyAppName. I checked the permissions for that folder and they were set correctly. Yet it did not fire off. Then, I "switched user" to John Admin, and the RunOnce key immediately ran the executable. Can you see anything I've done wrong?

            Thanks

            Comment

            • Anders
              Moderator
              • Jun 2002
              • 5632

              #7
              The RunOnce key only works for administrators.

              Since there can be more than one admin on a machine you don't know which of them is going to log in so you should store your state somewhere global.

              I'd suggest $windir\Temp or if you use "SetShellVarContext all" $appdata\yourcompany will map to c:\programdata\yourcompany
              IntOp $PostCount $PostCount + 1

              Comment

              • Austin71
                Junior Member
                • Jan 2014
                • 7

                #8
                I'm afraid I don't quite understand what you mean by "store your state somewhere global". I put my executable in the user-independent location $APPDATA\Temp\MyAppName, but if the RunOnce key only works for administrators, doing so does not completely solve my problem.

                I think the problem is that UAC sort of "hijacks" the install process. If Joe User logs in and tries to install my app, I can warn him to go get an admin to perform this, and also to have that same admin log in after the reboot, to complete the install. But if UAC is set high, then it immediately asks for admin credentials before my installer can advise the user what needs to be done. How is this generally handled? Or should I just assume that an administrator will be the one installing the software and will know how to complete the process (by logging in again after the reboot)?

                Comment

                • Anders
                  Moderator
                  • Jun 2002
                  • 5632

                  #9
                  If you absolutely have to be admin to complete the install maybe if some non-admin user runs your app before the install is complete you can prompt them to log in as admin or spawn the RunOnce commandline yourself...
                  IntOp $PostCount $PostCount + 1

                  Comment

                  • Austin71
                    Junior Member
                    • Jan 2014
                    • 7

                    #10
                    I think is a good suggestion to prompt them for an admin. I believe that I must have an admin because I am writing information into the HKLM, changing permissions in the Program Data\MyApp folder, and installing the app for "all users".

                    Thanks very much. Maybe I am trying to cover too many bases.

                    Comment

                    • Anders
                      Moderator
                      • Jun 2002
                      • 5632

                      #11
                      Why can you not do these things before the reboot?

                      Why do you have to reboot anyway?
                      IntOp $PostCount $PostCount + 1

                      Comment

                      • Austin71
                        Junior Member
                        • Jan 2014
                        • 7

                        #12
                        Well perhaps there is a flaw in my thinking. Here is what I am doing:

                        My installer installs my app and some associated hardware drivers. When the installer runs, it checks for the existence of a previous version. If it finds one, it uninstalls it as well as the hardware drivers. However it is my understanding that it is not possible to install new hardware drivers until after a reboot. That is why I am going to all this trouble. Does it sound correct that this would be the case?

                        Comment

                        Working...
                        X