Forum Discussion
Start OneDrive when windows starts - All domain computers
Hello,
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:
try placing the key here instead:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
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
7 Replies
- Lou_MickleyBrass Contributor
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: https://docs.microsoft.com/en-us/onedrive/use-group-policy#PreventNetworkTraffic
- rmoatBrass Contributor
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.
- dustintadamIron Contributor
try placing the key here instead:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
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
- rmoatBrass Contributor
dustintadam 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!
- dustintadamIron Contributor
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:
$ODClient = "https://go.microsoft.com/fwlink/?linkid=844652"$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 $outputStart-Process -FilePath $output -ArgumentList '/allusers', '/silent'Start-Sleep -Seconds 60Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Launch OneDrive" | Out-NullStart-ScheduledTask -TaskName "Launch OneDrive"Start-Sleep -Seconds 5Unregister-ScheduledTask -TaskName "Launch OneDrive" -Confirm:$false}