Simple python exe app doest not wrtite text to selected file whenever is stared by Task scheduller

30 views Asked by At

This is my simple code:

f = open("mytext.txt", "a")
f.write("Now the file has more content!")
f.close()

When I start it by Task Scheduller, I don´t see any error, but text is not wrotten in file after that. When I run exe or py file manually. It works normally.

1

There are 1 answers

1
Scoffield On

I would advise you to check a couple of things:

  1. See if the directory your program runs in is correct: Properties -> Action -> Double-click on "start a program" -> Check the path in "start in (optional):" setting. It could be that scheduler runs your exe in a different directory (and creates the file there)

  2. Check if User you run this task as has the rights to write in desired directory: Properties -> General -> Security options -> "When running the task, use the following user account:" that's the user that needs permission to write data in directory. Then, go to your directory and check: Properties -> Security -> %user% -> Writing is allowed.