WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: CadJoe on December 04, 2020, 02:21:48 PM

Title: Sched Task can't FileOpen
Post by: CadJoe on December 04, 2020, 02:21:48 PM
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 !
Title: Re: Sched Task can't FileOpen
Post by: td on December 04, 2020, 02:40:44 PM
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.
Title: Re: Sched Task can't FileOpen
Post by: CadJoe on December 04, 2020, 02:52:28 PM
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 !
Title: Re: Sched Task can't FileOpen
Post by: td on December 05, 2020, 09:17:39 AM
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.