none
Expandable string support for OneDrive.ADMX

    Question

  • Part of the supplied OneDrive.admx template has this section for the Default location of the OneDrive folder:

    ...

        <policy name="DefaultRootDir" class="User" displayName="$(string.DefaultRootDir)" explainText="$(string.DefaultRootDir_help)" key="SOFTWARE\Microsoft\OneDrive\Tenants\{INSERT YOUR TENANT'S GUID HERE}" valueName="DefaultRootDir">
          <parentCategory ref="OneDriveNGSC" />
          <supportedOn ref="windows:SUPPORTED_Windows7" />
          <enabledValue>
            <string>{INSERT YOUR CHOSEN PATH HERE}</string>
     </enabledValue>
     <disabledValue>
       <string></string>
     </disabledValue>
        </policy>

    ...

    The problem is that we wish to have the OneDrive folder in D:\Users\%USERNAME%; and the resulting registry key created when using this template (yes, I did add the GUID and path) is a standard string type (REG_SZ) and not an expandable string (REG_EXPAND_SZ) so that the variable %USERNAME% doesn't get expanded.

    The normal folder redirection Group Policy does allow for system variables (which we use), it seems there's been an oversight with the OneDrive template

    How can the OneDrive template be edited to produce a REG_EXPAND_SZ type instead? I've tried using <elements>...</elements> to wrap the data I want but I get an error "Expected one of the following possible elements... but found <elements> instead". Other attempts I've have resulted "Encountered an error while parsing" if I then try and edit the Group Policy.

    Hope someone can help  out - or maybe someone has already done this. Should this be listed as a bug?

    Ian


    Ian Broadbent

    Wednesday, February 22, 2017 5:35 AM

Answers

  • Should work like this:
         <policy name="DefaultRootDir" class="User" displayName="$(string.DefaultRootDir)" explainText="$(string.DefaultRootDir_help)" key="SOFTWARE\Microsoft\OneDrive\Tenants\{INSERT YOUR TENANT'S GUID HERE}">
          <parentCategory ref="OneDriveNGSC" />
          <supportedOn ref="windows:SUPPORTED_Windows7" />
          <elements>
             <text id="OneDriveSyncFolder" valuename="DefaultRootDir" expandable="true" />
          </elements>
        </policy>
     
    You also need to edit the OneDrive.adml. In the <stringtable> node add
    <string id="OneDriveSyncFolder">OneDrive Sync Folder</string>
    and in the <presentationtable> add
    <presentation id="OneDriveSyncFolder">
        <textBox refID="OneDriveSyncFolder">
            <label>OneDrive Sync Folder</label>
            <defaultValue>Whatever Value you like</defaultValue>
        </textBox>
    </presentation>
     
    You then need to enter the path not in the ADMX, but in the respective GPO itself.
     
    Wednesday, February 22, 2017 10:40 AM
  • Thanks very much for the reply Martin. I did get this working after a few modifications.

    I followed your guide above, I did initially get an error:

    <Policy definition "DefaultRootDir' contains elements, but it does not have a presentation resource reference.>

    So I then edited the .ADMX to include a "presentation=..." statement. I also edited  "valuename" to "valueName" to avoid another "Encountered an error while parsing" message.

    So my edits look like this:

    ---ADMX---

        <policy name="DefaultRootDir" class="User" displayName="$(string.DefaultRootDir)" explainText="$(string.DefaultRootDir_help)" presentation="$(presentation.DefaultRootDir_Pres)" key="SOFTWARE\Microsoft\OneDrive\Tenants\{INSERT YOUR TENANT'S GUID HERE}" >
          <parentCategory ref="OneDriveNGSC" />
          <supportedOn ref="windows:SUPPORTED_Windows7" />
          <elements>
             <text id="OneDriveSyncFolder" valueName="DefaultRootDir" expandable="true" />
          </elements>
        </policy>

    --ADML--

    in <stringtable>

          <string id="OneDriveSyncFolder">OneDrive Sync Folder</string>     

    in <presentationtable>

         <presentation id="DefaultRootDir_Pres">
           <textBox refId="OneDriveSyncFolder">
            <label>OneDrive Sync Folder</label>
            <defaultValue>%USERPROFILE%</defaultValue>
          </textBox>
         </presentation>

    Thanks again!


    Ian Broadbent


    • Edited by Ian Broadbent Thursday, February 23, 2017 1:30 AM remove spurious word
    • Marked as answer by Ian Broadbent Wednesday, March 01, 2017 12:43 AM
    Thursday, February 23, 2017 1:15 AM

All replies

  • Should work like this:
         <policy name="DefaultRootDir" class="User" displayName="$(string.DefaultRootDir)" explainText="$(string.DefaultRootDir_help)" key="SOFTWARE\Microsoft\OneDrive\Tenants\{INSERT YOUR TENANT'S GUID HERE}">
          <parentCategory ref="OneDriveNGSC" />
          <supportedOn ref="windows:SUPPORTED_Windows7" />
          <elements>
             <text id="OneDriveSyncFolder" valuename="DefaultRootDir" expandable="true" />
          </elements>
        </policy>
     
    You also need to edit the OneDrive.adml. In the <stringtable> node add
    <string id="OneDriveSyncFolder">OneDrive Sync Folder</string>
    and in the <presentationtable> add
    <presentation id="OneDriveSyncFolder">
        <textBox refID="OneDriveSyncFolder">
            <label>OneDrive Sync Folder</label>
            <defaultValue>Whatever Value you like</defaultValue>
        </textBox>
    </presentation>
     
    You then need to enter the path not in the ADMX, but in the respective GPO itself.
     
    Wednesday, February 22, 2017 10:40 AM
  • Thanks very much for the reply Martin. I did get this working after a few modifications.

    I followed your guide above, I did initially get an error:

    <Policy definition "DefaultRootDir' contains elements, but it does not have a presentation resource reference.>

    So I then edited the .ADMX to include a "presentation=..." statement. I also edited  "valuename" to "valueName" to avoid another "Encountered an error while parsing" message.

    So my edits look like this:

    ---ADMX---

        <policy name="DefaultRootDir" class="User" displayName="$(string.DefaultRootDir)" explainText="$(string.DefaultRootDir_help)" presentation="$(presentation.DefaultRootDir_Pres)" key="SOFTWARE\Microsoft\OneDrive\Tenants\{INSERT YOUR TENANT'S GUID HERE}" >
          <parentCategory ref="OneDriveNGSC" />
          <supportedOn ref="windows:SUPPORTED_Windows7" />
          <elements>
             <text id="OneDriveSyncFolder" valueName="DefaultRootDir" expandable="true" />
          </elements>
        </policy>

    --ADML--

    in <stringtable>

          <string id="OneDriveSyncFolder">OneDrive Sync Folder</string>     

    in <presentationtable>

         <presentation id="DefaultRootDir_Pres">
           <textBox refId="OneDriveSyncFolder">
            <label>OneDrive Sync Folder</label>
            <defaultValue>%USERPROFILE%</defaultValue>
          </textBox>
         </presentation>

    Thanks again!


    Ian Broadbent


    • Edited by Ian Broadbent Thursday, February 23, 2017 1:30 AM remove spurious word
    • Marked as answer by Ian Broadbent Wednesday, March 01, 2017 12:43 AM
    Thursday, February 23, 2017 1:15 AM
  • Hi,

    Just checking in to see if the information provided was helpful. And if the replies as above are helpful, we would appreciate you to mark them as answers, please let us know if you would like further assistance.

    Best Regards,

    Wendy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 27, 2017 7:17 AM
    Moderator
  • Hi,

    I have a similar inquiry. I want to set the OneDrive folder in C:\OneDrive\%username%\ I'm not sure to understand how exactly I should edit the OneDrive.admx and OneDrive.adml. 

    Wendy, could you guide me and tell me how should I arrange these lines ?

    <policy name="DefaultRootDir" class="User" displayName="$(string.DefaultRootDir)" explainText="$(string.DefaultRootDir_help)" key="SOFTWARE\Microsoft\OneDrive\Tenants\111111111111111" valueName="DefaultRootDir">
          <parentCategory ref="OneDriveNGSC" />
          <supportedOn ref="windows:SUPPORTED_Windows7" />
          <enabledValue>
            <string>c:\OneDrive\%username%</string>
      </enabledValue>
      <disabledValue>
        <string></string>
      </disabledValue>
        </policy>

    Thank you

    Monday, March 06, 2017 7:46 PM
  • Hi Benjamin,
    Thank you for posting in this thread, however, in order to offer more assistance, I would suggest you open a new thread for your detail questions.
    Appreciate for your cooperation.
    Best regards,
    Wendy

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, March 07, 2017 1:35 AM
    Moderator
  • Thanks very much for the reply Martin. I did get this working after a few modifications.

    I followed your guide above, I did initially get an error:

    <Policy definition "DefaultRootDir' contains elements, but it does not have a presentation resource reference.>

    So I then edited the .ADMX to include a "presentation=..." statement. I also edited  "valuename" to "valueName" to avoid another "Encountered an error while parsing" message.

    So my edits look like this:

    ---ADMX---

        <policy name="DefaultRootDir" class="User" displayName="$(string.DefaultRootDir)" explainText="$(string.DefaultRootDir_help)" presentation="$(presentation.DefaultRootDir_Pres)" key="SOFTWARE\Microsoft\OneDrive\Tenants\{INSERT YOUR TENANT'S GUID HERE}" >
          <parentCategory ref="OneDriveNGSC" />
          <supportedOn ref="windows:SUPPORTED_Windows7" />
          <elements>
             <text id="OneDriveSyncFolder" valueName="DefaultRootDir" expandable="true" />
          </elements>
        </policy>

    --ADML--

    in <stringtable>

          <string id="OneDriveSyncFolder">OneDrive Sync Folder</string>     

    in <presentationtable>

         <presentation id="DefaultRootDir_Pres">
           <textBox refId="OneDriveSyncFolder">
            <label>OneDrive Sync Folder</label>
            <defaultValue>%USERPROFILE%</defaultValue>
          </textBox>
         </presentation>

    Thanks again!


    Ian Broadbent


    Hi,

    In your example you noted that you edited the ADMX "So I then edited the .ADMX to include a "presentation" file but below you've mentioned that the presentationtable is in the ADML.

    Im currently working through this and was wondering if you could show me an example of your ADML and ADMX files so I can compare?

    Thanks

    Thursday, July 27, 2017 12:48 PM