Announcement

Collapse
No announcement yet.

Force Windows XP Compatibility and Run as Administrator During install.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Force Windows XP Compatibility and Run as Administrator During install.

    I need to force these settings during install if user has vista or windows 7. I cant rely on the user to right click properties. Can this be done with setup factory? Would someone explain how to do this?

    I need the installer to auto check :
    • Run program in compatibility mode Windows XP (Service Pack 3)
    • Run this program as administrator



  • #2
    Setting the compatibility mode for an application is achieved via the registry. You need to create a value in the registry after deploying the file, with an action similar to this:

    Code:
    if (not Registry.DoesKeyExist(HKEY_CURRENT_USER,
        "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers")) then
        -- create the key for storing the flag
        Registry.CreateKey(HKEY_CURRENT_USER,
        "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");
    end
    -- create AppCompatFlag in HKCU
    Registry.SetValue(HKEY_CURRENT_USER,
        "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",
        SessionVar.Expand("%AppFolder%\\application.exe"), "WINXPSP3 RUNASADMIN", REG_SZ);
    On x64 platforms, you need to perform this action with a native 64-bit setup, or you need to include the Wow64 plugin to write the registry value:

    Code:
    if (not Wow64.RegistryDoesKeyExist(HKEY_CURRENT_USER,
        "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",
        Wow64.KEY64)) then
          -- create the key for storing the flag
          Wow64.RegistryCreateKey(HKEY_CURRENT_USER,
          "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", 
          Wow64.KEY64);
    end
    -- create AppCompatFlag in HKCU
    Wow64.RegistrySetValue(HKEY_CURRENT_USER,
          "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",   
          SessionVar.Expand("%AppFolder%\\application.exe"), "WINXPSP3 RUNASADMIN",
          REG_SZ, Wow64.KEY64);
    The code above should work fine on both 32 and 64-bit platforms.

    Ulrich
    Last edited by Ulrich; 08-25-2012, 11:31 AM. Reason: added check with DoesKeyExist()

    Comment


    • #3
      explain

      What do you do with the code? Where do you place it in the setup?
      Thanks

      Comment


      • #4
        Put it in "Post Install Actions" -- remember to change it to point to your exe.

        Comment


        • #5
          Point

          remember to change it to point to your exe? how do you do this?
          Thanks

          Comment


          • #6
            This may be beyond your skill level.... but you need to change this part to point to your exe:

            SessionVar.Expand("%AppFolder%\\application.exe")

            Comment


            • #7
              where is this located?

              Comment


              • #8
                in the code Ulrich provided you.

                Comment


                • #9
                  yes you are right! (Beyond skill level) but with a little help I made it happen. Thank you!!

                  Comment

                  Working...
                  X