none
Using %usernam% variable in Registry or GPO

    Question

  • 2012R2 RDS environment

    I have an application that when first run needs to point user configuration files to a unique folder for each user.

    I have tried the following syntax but obviously I am missing something:

    This subkey is in HKLM

    LocalPath           REG_EXTEND_SZ          D:\APPCONFIG\%USERNAME%

    This results in the creation of a subfolder "%username% instead of "joeg" or "roberts".

    I have tried quotes and even double %% signs at each end, without success.

    Suggestions would be appreciated.

    Thanks >> Joe

    Wednesday, March 02, 2016 3:57 PM

Answers

  • > LocalPath           REG_EXTEND_SZ          D:\APPCONFIG\%USERNAME%
    > This results in the creation of a subfolder "%username% instead of
    > "joeg" or "roberts".
     
    Who creates this folder - the application itself? Then most probably the
    application is unaware of how to query for REG_EXPAND_SZ properly - if
    you query the binary data directly (or as a REG_SZ), you will always
    receive %USERNAME% and need to expand the variables on your own.
     
    To be on the safe side when I do things like that, I always expand them
    explicitly, but this has to be coded into the application.
     
     
    Wednesday, March 02, 2016 4:19 PM
  • I see what you are saying.

    I thought that the reg key created the folder, but this is simply information that is being passed to the application for it to deal with.

    It is an old app, so likely it was not designed to use REG_EXTEND_SZ.

    Thanks for the clarification.

    Best >> Joe

    • Marked as answer by JAGP Thursday, March 03, 2016 6:20 AM
    Wednesday, March 02, 2016 4:29 PM

All replies

  • > LocalPath           REG_EXTEND_SZ          D:\APPCONFIG\%USERNAME%
    > This results in the creation of a subfolder "%username% instead of
    > "joeg" or "roberts".
     
    Who creates this folder - the application itself? Then most probably the
    application is unaware of how to query for REG_EXPAND_SZ properly - if
    you query the binary data directly (or as a REG_SZ), you will always
    receive %USERNAME% and need to expand the variables on your own.
     
    To be on the safe side when I do things like that, I always expand them
    explicitly, but this has to be coded into the application.
     
     
    Wednesday, March 02, 2016 4:19 PM
  • I see what you are saying.

    I thought that the reg key created the folder, but this is simply information that is being passed to the application for it to deal with.

    It is an old app, so likely it was not designed to use REG_EXTEND_SZ.

    Thanks for the clarification.

    Best >> Joe

    • Marked as answer by JAGP Thursday, March 03, 2016 6:20 AM
    Wednesday, March 02, 2016 4:29 PM