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.
I would advise you to check a couple of things:
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)
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.