Shutil.move() not working with Task Scheduler despite working manually

Viewed 121

I'm working on using Task Scheduler to run this program every morning. The python program works fine when I run it manually, but throws a FileNotFoundError when done with Task Scheduler. Here is a snippet of the code:

original = "C:/Users/work/thing/thing.xlsx"
target = "C:/Users/{}/place of work/work Team - 
Documents/General/thing".format(user)

if os.path.isfile(os.path.join(target, "thing.xlsx")):
    os.remove(os.path.join(target, "thing.xlsx"))

shutil.move(original, target)

print("Program executed without errors.")
1 Answers

Fixed by converting the python script into an executable file (via pyinstaller) and then making the exe program the action from Task Scheduler. Some ticked properties include -"grant highest permissions" I also removed the need for shutil.move() by just creating and writing to a file in the cloud location.

Related