I want to make an app, that is located on %localappdata% folder (in a subforlder of it), to run on Windows startup, when it is installed for the user. I am able to do that if I create a string value under the key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run and set it to C:\Users\my_user\AppData\Local\programs\My_App\My_App.exe" --app_id=12346.

However, I don't want to put a direct reference to my user in it. So I've tried to, instead of putting C:\Users\my_user\AppData\Local, to use %localappdata% in the String value, so it looks like %localappdata%\programs\My_App\My_App.exe" --app_id=12346.

However, using the Local App Data reference doesn't work - the app doesn't launch. I wonder if there is a way of using a reference to %LocalAppData% inside a registry key - maybe I have a syntax error?

Could you help me with it?

I've already thought of creating a bat file to call my app, and put it into C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup, but it would run for all users, and I cannot guarantee all users will have my app installed. So that wouldn't be a good choice.


Names %AppData% and %LocalAppData% contain word "Data", giving you the hint that these directories should not be used for storing executable files. Please don't do that.

I would change the design of the entire thing.

  1. Put the application into standard location for applications:

    • if it has an installer, use %ProgramFiles%\My_App\ or %ProgramFiles(x86)%\My_App\
    • if it comes without installer, I would use something like C:\Tools\My_App\
  2. Insert autorun entries either to HKCU Registry subtree (for individual user) or into HKLM subtree (for local machine = all users)

  3. When the application is launched, it has full access to name of user, paths of all user directories etc. So start doing your user-dependent stuff only after the application was launched. This way you are no longer dependent on location of EXE file or similar magic.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.