USB Working-Hours Rule Not Working: Why the Schedule Fails and How to Fix It
A USB working-hours rule that does not switch leaves storage open at night or closed during the day. This page diagnoses the Windows 10 and Windows 11 versions of that failure, where Task Scheduler writes the Deny_All value. It assumes you already built the tasks.
A working-hours USB rule fails at one of five points: the task never fires, SYSTEM cannot start the script, the script writes the wrong value, the drive was already mounted, or another policy writes the same value. Read the task’s Last Result, then the Deny_All value, then retest with an unplugged drive.
| Applies to | Windows 10 22H2, Windows 11 |
|---|---|
| Time needed | 10 to 15 minutes |
| Difficulty | Moderate |
| Cost | $0 |
| Needs admin or internet | Administrator yes, internet no |
| Last verified | November 2026 |
Read the Task Chain from Left to Right
A working-hours rule that does not switch breaks at one of five links: the trigger fires, SYSTEM starts PowerShell, the script reads the clock, the Deny_All value changes, and the drive obeys on its next connection. Find the first broken link and the rest of the chain usually behaves.
This page is part of our guide to allowing USB access only during working hours, which holds the script and the three tasks. If the setup is not built yet, start there.
Check the task’s Last Result
Run schtasks /query /tn "USB Hours Close" /v /fo list and read Last Result. Microsoft’s Task Scheduler constants give the common values:
| Last Result | Meaning | What to do |
|---|---|---|
| 0x0 | The operation completed successfully | The task ran; go to the value check |
| 0x1 | Incorrect or unknown function called | Check quotes and the script path in the /tr argument |
| 0x2 | File not found | The script path is wrong or the folder moved |
| 0x41301 | The task is currently running | Wait, then query again |
| 0x41302 | The task is disabled | Enable it in Task Scheduler |
| 0x41303 | The task has not yet run | Run it by hand; check triggers and conditions |
Check the value, not the task
A result of 0x0 proves the action ran, not that it wrote what you expect. Read the value directly with reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices" /v Deny_All. If it reads 0x0 at night, the script chose the open state: the usual cause is a close time that was typed as 1800 minutes instead of 1080, so check the two numbers.
Sleep, Hibernate and Missed Triggers
A task cannot run while the PC sleeps or hibernates, so a laptop closed at 17:55 never sees its 18:00 trigger. Two settings cover it: the option to run as soon as possible after a scheduled start is missed, and the startup task that applies the correct state at every boot.
Open the task properties
Launch taskschd.msc, select the task and choose Properties.
Open the Settings tab
Tick the option to run the task as soon as possible after a scheduled start is missed.
Review the Conditions tab
Untick any option that stops the task on battery power if the laptop will be unplugged at closing time.
Keep the startup task
The USB Hours Startup task re-evaluates the clock at each boot, so a morning start-up lands in the right state without any missed trigger.
Mounted Drives and Installed Drivers
Windows remembers a device after its first connection, so a drive that was plugged in when the state changed can stay usable until you remove it. Microsoft Tech Community guidance says that once a driver is installed, prevention is no longer available until the driver is removed.
The practical test sequence is always the same. Unplug every drive. Run the closing task. Confirm Deny_All reads 0x1. Plug in the spare. If the drive opens even then, try the USBSTOR switch in the main guide, since Deny_All acts through policy and USBSTOR acts on the driver itself. The NinjaOne walkthrough of disabling USB drives describes the USBSTOR route and notes that an error appears in Device Manager for the blocked storage device.
Changing state while a drive is plugged in is the single most common false failure. Treat any test that started with a plugged-in drive as invalid.
Two Writers, One Value: Policy and Management Conflicts
If another tool writes the Deny_All value, your script and that tool take turns winning. Intune writes this key when a device restriction blocks removable storage, according to Microsoft Tech Community answers, so an enrolled PC can quietly undo the rule at its next sync.
To find a second writer, run gpresult /r and read the applied objects, then ask whoever manages Intune or any endpoint product whether a removable-storage policy is assigned to the PC. Remove it, or let it be the only writer and drop the script. One value should have one owner.
| Source | How to spot it | Fix |
|---|---|---|
| Domain Group Policy | gpresult /r lists an object with Removable Storage Access | Set it to Not Configured or retire the script |
| Intune device restriction | Removable storage set to Block in the profile | Change the profile, or accept it as the owner |
| Another security tool | A device-control module in its console | Disable its USB feature or pick one tool |
| Old manual edit | Deny_All already present from an earlier test | Reset the value to 0 and re-run the tasks |
Symptom
Value flips back within minutes.
Works on one PC, not its twin.
First check
A management sync or policy refresh.
A different policy set on the second PC.
When the Software Layer Is the Missing Piece
If your actual problem is that a drive must stay usable for one person while everyone else is blocked, scheduled tasks are the wrong tool; an allow-list is the right one. USB Block’s Program Options page shows a stealth mode, protection in Safe Mode, a master key and attempt monitoring.

Read the product’s own page at the USB Block product page before buying: it documents the allow-list, password prompt and log, and states the supported Windows versions. It does not document a timetable.
The left-to-right rule: check trigger, launch, script, value, drive, in that order, and stop at the first failure. Fixing a later link first hides the real cause.
Questions on this topic
Why does my scheduled USB block run but the drive still opens?
The drive was almost certainly mounted before the state changed. Windows keeps an installed device working until it is removed, so unplug it, run the closing task, and plug it in again. If it still opens, read the Deny_All value; a 0x0 means the script wrote the open state.
What does Last Result 0x41303 mean for my USB task?
It means the task has not yet run. The trigger time has not arrived, the task is disabled by a condition, or the trigger was never created. Run the task by hand with schtasks /run and read the result again; a 0x0 confirms the action itself works.
Will the rule fire if the PC is asleep at closing time?
No. A sleeping PC runs no tasks, so the previous state stays in force until it wakes. Tick the option to run as soon as possible after a missed start, and keep the startup task so a reboot also corrects the state.
How do I find out if another policy is changing the value?
Run gpresult /r in an elevated prompt and look for applied policy objects that touch removable storage, then check whether the PC is enrolled in Intune. A management tool that writes the same key will overwrite your script on its next sync.
Can I test the rule without waiting until 18:00?
Yes. Run each task by hand with schtasks /run. The script reads the real clock, so for an out-of-hours test temporarily change the close time in the script to a minute that has already passed, then restore it.
Add the approved-drive layer
USB Block adds an allow-list, a password prompt and a device log to a Windows PC. Its product page does not document a timetable, so use it beside the scheduled tasks, not instead of them. The page lists Windows 10, 8 and 7 and Windows Server 2008 to 2019.