Announcement

Collapse
No announcement yet.

App Data LocalFolder Folder

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

  • App Data LocalFolder Folder

    Just trying to see if it's possible to create a custom variable for "\User\%username%\AppData\Local". I know it's possible to use %ApplicationDataFolder% to get to "\User\%username%\AppData\Roaming". Sorry for the ignorance kinda newbie.


  • #2
    Any of these should work:
    Code:
    sFolder = Shell.GetFolder(SHF_APPLICATIONDATA_LOCAL);
    sFolder = Shell.GetFolder(28);
    sFolder = os.getenv("LOCALAPPDATA");
    Ulrich

    Comment


    • #3
      Thanks for the reply Ulrich!
      Can I use the varaibles in Session Variables tab in the "Project Settings" window?

      Comment


      • #4
        You can, as long as you define a custom Session Variable and initialize it properly in the On Startup event script.

        Click image for larger version

Name:	SCRN-2019-11-20-02.png
Views:	418
Size:	29.2 KB
ID:	304189

        Click image for larger version

Name:	SCRN-2019-11-20-04.png
Views:	338
Size:	9.6 KB
ID:	304190

        You can then use this custom Session Variable in the same manner as the built-in in scripts:

        Click image for larger version

Name:	SCRN-2019-11-20-05.png
Views:	427
Size:	23.2 KB
ID:	304191

        You can use it also as target path for deployment:

        Click image for larger version

Name:	SCRN-2019-11-20-06.png
Views:	320
Size:	6.9 KB
ID:	304192

        Ulrich

        Comment


        • #5
          Thanks I will give it a try!

          Comment


          • #6
            This solution does work on Windows if you are installing as the Administrator Level user for that Administrator level users to use. However if you need to install it for a different users for instance user Anthony (a non admin user), I could try to install it in admin and %LocalAppData% will point to something like C:\Users\Admin\AppData\Local\ which will not work for the Anthony user. If I try to install with Anthony I will get an admin prompt, but it will still install under C:\Users\Admin\AppData\Local\ when I want it to install as C:\Users\Anthony\AppData\Local\.

            Do you have any suggestions on the best way to resolve this?

            Comment


            • #7
              It is a bit unclear what your application requires, if I misunderstood, please explain a bit more. The process with admin rights should most likely not deploy files into the user's profile, because by default the user will be unable to change those files later, as he isn't the owner.

              I assume that you are attempting to install an application, and each user has his/her own custom files in the profile. So one way to handle this is deploying the files as admin in the ProgramFiles and ProgramData folder as needed. Your application, on the first execution when it is unable to find the expected files in the user profile, could copy the default files from ProgramFiles or ProgramData into the desired folder in the user's profile, where they later can be updated with the user's settings. As the application is running in the user's context, the copied files and created folders will receive the proper access rights so the can be updated at runtime during normal operation of the program.

              When another user on the same PC runs the application, again, the files would be copied once if they cannot be found, and accessed from that moment on for later uses.

              Unless the application should not be shared will all users, in this case the setup also could not be run "as administrator" but "as invoker" instead, and you would be able to deploy everything into the user's profile, instead of using ProgramFiles or similar shared folders.

              Ulrich
              Last edited by Ulrich; 04-09-2020, 09:03 PM.

              Comment


              • #8
                Thanks Ulrich, for your help on this, yes our development software does work like this on macOS, but unfortunately doesn't work this way on Windows. On Windows each user needs specific files in their Users\UserName\AppData\Local\ProgramName folder. It's not the greatest solution for deploying. I am going to contact the company to see if there is a way to deploy since the startup routines may not be editable for us.

                Comment


                • #9
                  I was wondering if it is possible to get name of the user that launched the installer file? Is there anything in setup factory that would point me to that or a way to look at the user before the user elevation happens?

                  Comment


                  • #10
                    Yes, collect the launch user information in the build settings...

                    Ulrich

                    Comment


                    • #11
                      Ah yes, thank you. Interesting I see if this checked box isn't checked %Launch...% variables are the invoker...

                      Comment

                      Working...
                      X
                      😀
                      🥰
                      🤢
                      😎
                      😡
                      👍
                      👎