Start OneDrive when windows starts - All domain computers

Occasional Contributor


I'm trying to figure out if there is a way we can push out a script that will enable the OneDrive startup key. Just a small background on this, prior to my time at my company, OneDrive was disabled on all computers, including the use of the DisableFileSyncNGSC key. Removing these keys doesn't allow OneDrive to start up automatically. So far, the only way I've found out how to get it to start up, is to go into the settings of OneDrive and click the "Start OneDrive automatically when I sign in to Windows". This creates the following OneDrive registry key:

C:\Users\<username>\AppData\Local\Microsoft\OneDrive\OneDrive.exe" /background
However, we have 1,300+ machines and it would be nice if there was a way to somehow push this out to everyone so they didn't need to go in and enable it themselves (since most won't even read the instructions to do it).
The problem is, creating a registry key for each unique user per machine doesn't quite work so well. I tried creating one like this:
%userprofile%\AppData\Local\Microsoft\OneDrive\OneDrive.exe /background, but using the %userprofile% environment variable doesn't work. Is there anything I can do to force every machine to start OneDrive automatically? We want to use Known Folder Move for all of our users, but OneDrive has to start each time to ensure that syncing happens.
7 Replies
best response confirmed by rmoat (Occasional Contributor)



try placing the key here instead:




that should force it to run for all users on the device and you wont have to try and figure out how to inject into HKCU

@Dustin Adam Thank you, that makes sense and will definitely work. Also, it just occurred to me, OneDrive can be installed for All Users by running OneDriveSetup.exe /allusers /silent.


Basically we could push that out to all computers as well, and the OneDrive client is then moved/installed to C:\Program Files (x86)\Microsoft OneDrive, which also makes updating run entries easier just to point at that location instead of the user folder.

Both seem like they'll work great. Thanks for your help!



Yup, you can, in fact, if you want, here's the script we use when imaging computers (we use InTune and AutoPilot, but this will work with anything as it's just PowerShell)


It'll download whatever the current production release of the Sync client is and install it for all users:


$output = "$ENV:temp"  + '\OneDriveSetup.exe'
$apppath = "C:\Program Files (x86)\Microsoft OneDrive\OneDrive.exe"
$action = New-ScheduledTaskAction -Execute $apppath
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date)
Invoke-WebRequest -Uri $ODClient -OutFile $output
Start-Process -FilePath $output -ArgumentList '/allusers', '/silent'
Start-Sleep -Seconds 60

Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Launch OneDrive" | Out-Null
Start-ScheduledTask -TaskName "Launch OneDrive"
Start-Sleep -Seconds 5
Unregister-ScheduledTask -TaskName "Launch OneDrive" -Confirm:$false


@Dustin Adam Wow, that's great, and extremely helpful. Really appreciate this. Thank you, thank you! This will help with our deadline in a month to roll it out to everyone.

no problem, let me know if you need anything else.

@rmoat also check to make sure 

[HKLM\SOFTWARE\Policies\Microsoft\OneDrive]"PreventNetworkTrafficPreUserSignIn" is NOT set to 1.  Setting it to 1 will prevent OneDrive from starting with Windows until the user logs in the first time.  Then it should start with Windows going forward.  you can also read more here: 

@Lou Mickley Thank you also! I missed this notification. This is helpful, as we're going to start using Intune to do some of these OneDrive tasks now, and this was a question we had come up just yesterday.