How to start OneDrive (and automatically sign-in) when using a RemoteApp in Windows Virtual Desktop (WVD)

Recently I had a use case where a customer uses Windows Virtual Desktop with RemoteApps, and files had to be opened and saved on the user’s OneDrive within these applications. Not a very exceptional situation if you ask me.

I know that with some GPO settings / registry keys you can configure silent sign-in and Files on-demand (recommended within environments like Windows Virtual Desktop). However, when configuring those settings, everything was working fine in a full published desktop, but not in a Windows Virtual Desktop RemoteApp.

When starting a RemoteApp, for example WordPad and open File > Open, OneDrive is visible on the left site, but no account is configured as shown in the screenshot below.

For applications such as Microsoft Word and Microsoft Excel, this is not a problem because OneDrive is built-in, but for all other non-Microsoft Office applications this is really a problem. I searched the internet on forums and found out that a lot of other people are facing the same problems, even within on-premises Citrix environments.

After some searching on the Microsoft and Citrix tech forums and testing I was able to solved the problem by applying the following registry keys via a GPO policy to the Windows Virtual Desktop environment;

For silent Account Config and Files On Demand:

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\OneDrive]
"SilentAccountConfig"=dword:00000001
"FilesOnDemandEnabled"=dword:00000001

To trigger OneDrive in a RemoteApp:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\RailRunonce]
"OneDrive"="C:\\Program Files (x86)\\Microsoft OneDrive\\OneDrive.exe /background"

“Magic” key to let it all work, even the first time a user logs in:

[HKEY_CURRENT_USER\Software\Microsoft\OneDrive]
"EnableADAL"=dword:00000002

After applying all the keys it worked fine, as shown in the screenshot below.

Once again I did not found this solution myself, I found it (in parts) on the Microsoft Tech Community forum, so all kudo’s to @Marcel Biebricher and @racook for providing part of the solution #Community

40 comments

  • I have been using this reg keys for months, but for many users OneDrive gets disconnected after a while, and no login window is visible with RemoteApps. They just see that nothing gets synced. In full desktop they see the red X and can log in again, then all is good even with RemoteApps afterwards. Anyone else seen this?

    • I haven’t seen that yet, but what I see is that the OneDrive icon from the WVD environment is also visible on the local client in the system tray. If you are facing this problem, do you also see the red X locally?

      • I just got the problem with a user now, and the local icon showed the circle/arrows, no red x. Can you interact with the icon at all? I cant, but i guess thats right. This time however, i got an dialog saying “user not signed in”. I clicked sign in, and all was good again. Normally this dialog just doesnt appear.

          • Thought that this setting is not needed anymore in the lastest onedrive version right ?

          • @Vincent is right. with the new version, the setting is not needed anymore.
            I however have tried everything you mentioned in your article but it doesn’t work for me. i have now logged a ticket with Microsoft. lets see what they say.

  • Hello. Ive been trying to get this work but I have only been partially successful. Despite having this reg key in place, users logging in for the first time hang during the login, with Microsoft OneDrive (32 bit) and Run Once Wrapper processes running in their session. If I kill Microsoft OneDrive (32 bit) in their session, the login immediately proceeds and OneDrive is actually setup and working for them. If I dont kill the process, the end user will eventually login but it takes between 5 and 10 minutes for this to happen. Has anyone seen this behavior?

    • Yes I did, but only with a new server where a user logs in for the first time (second user has no problems, and first user has also no issues the second time he/she logs in). Did not investigate this further at this moment.

      • I am also experiencing this. It is not only with the first user that logs in. It seems to be the first time any user logs into a RemoteApp session on a particular server.

        • Did you manage to solve this Alex ? We have the same problem, cannot use onedrive now…

          • Guys,

            I believe I have the fix for this. I’ve spent numerous hours troubleshooting why new user logins were taking so long, but then their subsequent login times were as expected.

            Turns out their is a RunOnce string value in the default user profile registry hive. As you know, new user logins create their new profile from the Default user profile. The RunOnce string value that is applying to the new user profile is attempting to run OneDrive.exe in the background and set it to auto-start, but in the wrong shell for RemoteApp purposes. This conflicts with the RailRunonce registry change you would have made earlier.

            1. Open Windows file explorer. On the view tab, select the check-box next to hidden items.
            2. Open your registry editor, and expand HKEY_USERS
            3. From the file menu select load hive.
            4. Browse to C:\Users\Default (note this folder is typically hidden) and select the NTUSER.dat file
            5. Give the hive a name so that it can be distinguished.
            6. In the newly loaded hive containing the default user profile, browse to Software\Microsoft\Windows\CurrentVersion\RunOnce
            7. If you installed OneDrive using the machine-wide installation, you will see a string called OneDrive, with the following value:
            C:\Program Files (x86)Microsoft OneDrive\OneDrive.exe /background /setautostart
            8. Delete the OneDrive string, and then collapse the default user profile hive.
            9. With the default user profile hive selected, click the file menu and choose Unload Hive. Say yes to the confirmation window.
            10. Login to RemoteApp with an account that does not have an existing profile created.
            11. Don’t forget to uncheck hidden items in the Windows File Explorer when you’re done.

            My initial logins for new users went down from 5+ minutes to only 25 seconds after making this change. As a bonus OneDrive works on first login as well.

            I hope this helps!

  • Hello, We are facing issue where users started complaining, when they login to WVD onedrive gives them error saying ” Onedrive cannot connect to windows” and error message is ” Files-on demand requires a connection in windows in order to show your files without taking up space on this device. Onedrive keep trying….”
    Any suggestions on how to resolve this issue?
    We have delete user profile, but still no luck , trying search online but no help their either.
    Any help is appreciated and thanks for clean guidence!

    • Can you check if all registry files are applied on your WVD host as described in this blog? Have the users SSO in the Microsoft Office applications? Is it activated? (just to check if SSO is configured correctly).

      • Thank you for getting back to me.
        We are not publishing onedrive as remote app. It’s in Windows 10 image itself.
        And it works for few times when user log-in but after second or third sign-in it just gave them error. We have sso turned on is working perfectly fine.
        Please see this link screenshot of error message.
        https://ibb.co/dGwrM8R

        Thank you again for your help!

  • Hi,
    Is this one really with double slashes in the path ?
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\RailRunonce]
    “OneDrive”=”C:\\Program Files (x86)\\Microsoft OneDrive\\OneDrive.exe /background”

    • you can actually set this as”

      “OneDrive”=”C:\Program Files (x86)\Microsoft OneDrive\OneDrive.exe” /background

      i.e. just the full path to onedrive.exe in double quotes with single forward slashes.

  • For the [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\RailRunonce]
    “OneDrive”=”C:\\Program Files (x86)\\Microsoft OneDrive\\OneDrive.exe /background” is it something you have to add in the registry of the WVD machine or should it be there.? I’m not seeing it.

  • In my environment (WVD / Win10 multi-session 1909) and the latest production OneDrive build, everything worked perfectly *except* for first logon for RemoteApp users.

    The same user logging onto the same WVD host with a full desktop session got the seamless first-time sign on and configuration, but never with RemoteApp. The RailRunonce value is in place.

    “EnableADAL”=dword:00000002 fixed the first run issue, so it does still seem to be necessary in this particular scenario.

  • I’m desperate as I can’t make it work. I have the keys as you have, I tried ”C:\Program Files (x86)\Microsoft OneDrive\OneDrive.exe” /background does not work, EnableADAL set to 1 does not work, I tried all combinations, weird thing is that I make it work in one of my VDIs part of my hostpool but not in the second one. The firstone I configured manually, as my GPO wasnt working, when I got it to work I replicated the same to be done using GPO, but is not working. Keys are applied just fine but i’m still not able to have my OneDrive profile loading as I open the remote app. any suggestion will be more than welcome.

    • Have you also test it with EnableADAL set to 2 ? Two weeks ago I tested it with the value to “1” it didn’t work either. With the setting to “2” it works fine.

      • i have tested it with both values (i.e. 1 and 2). it didn’t work. i have currently logged a case with MS. i will update you guys once we get it working.

        • OneDrive support answer is that this schema is not supported, that’s why it half works, i’m disappointed … I’ll let you know what they say about the alternate option. Did you get any response from your side?

        • Hi Shehzad,

          I have exactly the same problem (using the 2004 Windows 10 with Office 365 WVD). What did Microsoft tell you?

      • Thanks for responding back!! Yes I did, all combinations posible… at first I was a little confuse about the registry keys, I don’t know what else I could check… maybe the type of registry keys are not the correct ones? I was thinking deploy a small environment with a hostpool of w10 multisession with Office and see if that makes any diferente. What do you think? I have an open case as well with OneDrive but haven’t get any answer.

      • I have just tested this extensively on the newest prod version of W10 and OneDrive and it doesn’t work. If anyone comes up with a solution ir gets it working, please reply 😉

  • I was able to make it work in two new WVD with MS 364 apps and it worked at once, same GPO that I was using previously , however i’m having a lot of issues with the synck of the files, particularly when users connect to one of the VMs. I spoke with MS support and they said this is not supported, i’m confused right now, we need a way to securely download files generated through a remote app to our desktops. They said they will revert back with a workaround, ill share the results!

  • Does this works in Server 2019 RDS? I cant locate the ProgramFiles\OneDrive on the C-drive on the server.

      • Hi Robin,
        We have RDS 2019 and OneDrive Machine based Sync Client installed ( “OneDriveSetup.exe /allusers” ) but when the user first user logs in first server, the OneDrive is getting Configured and user can save the Office Document to OD as default, but when the same user logs in 2nd time with the 2nd Server, OneDrive is not getting Configure for him. We have Onprem AD Joined RDS not the Azure Joined. Any additional settings needed here ?

  • Do you know if this should work for Citrix? I am testing this but it does not work for citrix for me. When i apply the runonce.exe /alternateshellstartup it works but then all my run key entries start as well and that is not what i want. Anyone any idea?

  • Thanks for the writeup and I did see where you were working with some folks on an MS forum on this.

    I’m still having an issue just getting onedrive to auto-login even on the desktop app group. I’m using the gpo and have the settings right (as far as I can tell) and even with a test user with no MFA onedrive still won’t auto-login.

  • Hmm.

    I can’t seem to get it to login silently even on the full desktop.

    I have all the stated reg keys (some from GPO; some manually added) and still onedrive needs a separate login.

    This is on a Win10MU1909 Host logging in as a test user with no MFA and an E3 license.

    Any ideas? I put the magic key in and everything but still need to login manually..

  • Hello, Frist thanks for this post it is exactly what I am after, I am just stuck at this bit:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\RailRunonce]
    “OneDrive”=”C:\\Program Files (x86)\\Microsoft OneDrive\\OneDrive.exe /background”

    On my systems, There is no RailRunonce folder, any ideas?

  • It works for me except when user saves a file to a OneDrive folder while in RemoteApp mode, the file doesn’t get uploaded to OneDrive it just shows the sync icon on the folder forever. how to overcome this? configured registry settings as mentioned in the beginning in this post

About Robin Hobo

Robin Hobo

I work as a Senior Solution Architect with focus on the Modern Workspace. I am specialized in Azure Virtual Desktop (AVD), Windows 365 and Microsoft EM+S (including Microsoft Endpoint Manager - Microsoft Intune).

For my full bio, check the About Me page. You can also join me on the following social networks:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close