viewpoint-particle

Author Topic: Sched Task can't FileOpen  (Read 405 times)

CadJoe

  • Newbie
  • *
  • Posts: 20
Sched Task can't FileOpen
« 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 !

td

  • Tech Support
  • *****
  • Posts: 4092
    • WinBatch
Re: Sched Task can't FileOpen
« Reply #1 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

CadJoe

  • Newbie
  • *
  • Posts: 20
Re: Sched Task can't FileOpen
« Reply #2 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 !

td

  • Tech Support
  • *****
  • Posts: 4092
    • WinBatch
Re: Sched Task can't FileOpen
« Reply #3 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade