I'm having a frustrating issue with Task Scheduler. I developed a scheduled task that runs perfectly in my lab, which is a Virtual Windows 11 Pro connected to a Windows Server 2019 domain. I've ensured that all settings are identical between my VM and the physical workstation, and I'm logged in as a standard domain user on both. The task is set to run with elevated privileges, but it only works in the VM. When I try to execute it on the workstation, I get various errors including "Access is denied" and it sometimes shows a return code other than 0. I've double-checked everything, and I really need help figuring out what I'm doing wrong.
1 Answer
It sounds like you're having some permission issues. Are you sure that there aren't any elevated credentials stored in the Windows Credential Manager on your VM? That might be causing it to work there but not on the physical machine. If you're trying to run scripts that need admin access, I had similar success with a PowerShell script instead of using Task Scheduler directly.
I'm mounting a virtual hard drive which requires admin rights to run diskpart. The setup works on my VM because I created the task under the domain user profile and later elevated it using admin credentials. This approach might help you too.