Announcement

Collapse
No announcement yet.

Help to associate extension with exe

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

  • Help to associate extension with exe

    I use the following in Post install action:
    Registry.SetValue(HKEY_CLASSES_ROOT, ".gbl", "", "GBLight", REG_SZ);
    Registry.SetValue(HKEY_CLASSES_ROOT, "GBLight\\shell\\open\\command", "",SessionVar.Expand("%AppFolder%\\GBLightSP.exe\\ \"%1\""), REG_SZ)
    Registry.SetValue(HKEY_CLASSES_ROOT, "GBLight\\DefaultIcon", "", SessionVar.Expand("%AppFolder%\\LogoLight.ico,0"), REG_SZ);

    EXE not accosiated nad file not associated with Icon.

  • #2
    In registry: GBLight/shell/open/command/
    C:\GBLightSP\GBLightSP.exe\"%1"
    To normally associate file it shod be:
    "C:\GBLightSP\GBLightSP.exe" "%1"
    but SUF not give me ability to do that.

    Comment


    • #3
      Josh has posted Lua code for registering a file association in these forums. Here is a slightly modified version:

      Code:
      cExt = ".sf8";
      cExe = SessionVar.Expand("%AppFolder%\\application.exe"); -- program to open the file
      cIcon = SessionVar.Expand("%AppFolder%\\application.exe"); -- could also be a path to an icon
      cShort = "MyFile"; -- this will build "MyFile.Document" (cKey), the short description in registry
      cLong = "My Application Document"; -- the long description
      
      
      function File.SetAssociation(cExt, cExe, cIcon, cShort,cLong)
          -- Set the file association for the given file.
          local cKey = cShort..".Document";
      
          Registry.SetValue(HKEY_CLASSES_ROOT, cExt, "", cKey);
          Registry.SetValue(HKEY_CLASSES_ROOT, cKey, "",cLong);
          Registry.SetValue(HKEY_CLASSES_ROOT, cKey.."\\DefaultIcon","",File.GetShortName(cIcon)..",0");
          Registry.SetValue(HKEY_CLASSES_ROOT, cKey.."\\shell\\open\\command", "", "\""..cExe.."\" \"%1\"");
      end
      
      function File.RemoveAssociation(cExt)
        -- Remove the file association for the given file.
        local cKey = Registry.GetValue(HKEY_CLASSES_ROOT, cExt,"");
          
        if (cExt ~= "") then
          Registry.DeleteValue(HKEY_CLASSES_ROOT, cExt, "");
          if (cKey ~= "") then
            Registry.DeleteValue(HKEY_CLASSES_ROOT, cKey.."\\DefaultIcon", "");
            Registry.DeleteValue(HKEY_CLASSES_ROOT, cKey.."\\shell\\open\\command", "");
            Registry.DeleteValue(HKEY_CLASSES_ROOT, cKey, "");
          else
            SetupData.WriteToLogFile("Error\tFile extension '" .. cExt .. "' is unregistered!\r\n", true);
          end
        else
          SetupData.WriteToLogFile("Error\tCannot delete association for empty file extension!\r\n", true);
        end
      end
      Ulrich
      Last edited by Ulrich; 05-27-2014, 10:42 AM.

      Comment


      • #4
        Code does not work!

        This code does not work in SUF
        Syntax Error, Line=2 unexpected symbol near '%'

        Comment


        • #5
          Insert the missing quote. You are welcome.

          Ulrich

          Comment


          • #6
            Where to insert quote?

            Comment


            • #7
              You need to insert the quote on line 2, near "%", as the error message tells you.

              Ulrich

              Comment


              • #8
                Ok.
                Where is better to put this functions?
                Where is better to call this functions?

                Please, give me detailed instructions.

                Comment


                • #9
                  No icon associated with file.

                  Code set value:
                  C:\GBLIGH~1\GBLIGH~1.EXE,0
                  Is it correct?

                  Comment


                  • #10
                    You can place the function definitions into the "Global Functions". The association would set in the "On Post Install" script, and the association would typically be removed in the "On Pre Uninstall" script.

                    Ulrich

                    Comment


                    • #11
                      Icon not associated

                      Icon not associated with my *.GBL extension.

                      Comment


                      • #12
                        When I click on file property - Icon shown, but in Windows explorer not in any mode.

                        Comment


                        • #13
                          Please post your project file here, or attach it when you open a technical support ticket.

                          Ulrich

                          Comment

                          Working...
                          X