Sched Task can't FileOpen

Started by CadJoe, December 04, 2020, 02:21:48 PM

Previous topic - Next topic

CadJoe

Using FileOpen to Write a txt file.

Works fine when running manually, but think I'm running into Profile or UAC issues with SchedTask.
Exe is on an local E: drive, so not in System or Remote Server location, and

Windows 10 Pro.
I have it scheduled to Runas Windows 7, 2008R2.

When I change to Run Only when User Logged in, it gives me a 1077 FileOpen Failed Error of 5.

Would any of the IntControls like 39 or 40 help here ?

Thanks,

CadJoe
WinBatch, Gotta Love It !

td

The IntControls you mention would only help if some other process has the file open. That doesn't seem likely. Error 5 is the "Access Denied" error so you need to figure out why your script does not have access to the folder/file.  If it is a UAC issue because your scheduled task is not running with elevated privileges, you need to either change the access permissions to the file and or folder or change the configuration of your task to run with elevated privileges. Generally, this can be accomplished by setting the task to "Run with highest privileges" assuming an admin account.

FWIW, down OS-ing a WinBatch script usually causes more issues than it solves unless you are using a very old version of WinBatch.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

CadJoe

hmm, ok.

Added NTFS of Everyone, and it didn't seem to help.
Thinking since the Sched Task Repeats, a previous process thread might have locked it.

A reboot, and it works again, go figure.

When in doubt , its an MS issue.. hehe

Thanks,

CadJoe
WinBatch, Gotta Love It !

td

If a "previous process thread might have locked it", you either have a bug in your script, i.e., this script is not properly cleaning up after itself, or your scheduled task is not configured correctly.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade