Query and set Files On-Demand states in Windows

With OneDrive Files On-Demand, files can be in one of three states. Each of these states corresponds to a file attribute state. To query the current state of a file or folder, use the following command:

  • attrib <Path to file or folder>

Scriptable commands

Use the following commands to set file and folder states.

Files On-Demand state File attribute state Command
Always available
Pinned
attrib +p <path>
Locally available
Clearpin
attrib -p <path>
Online-only
Unpinned
attrib +u <path>

Note

Pinning an online-only file makes the sync app download the file contents, and unpinning a downloaded file frees up space on the device by not storing the file contents locally.
To set an online-only file or folder to "locally available," you must first set it to "always available."
If you meet the Sync app requirements and still can't see the Files On-Demand option under "Settings", make sure the service "Windows Cloud Files Filter Driver" start type is set to 2 (AUTO_START). Enabling this feature sets the following registry key value to 2.[HKLM\SYSTEM\CurrentControlSet\Services\CldFlt]"Start"="dword:00000002"