4

I am trying to schedule a python script which has been converted to .exe file but for some reason it is not starting. Although the program does seem to open a cmd type window but the script does not work. Below i have outlined the steps which i took, please advise if i have missed something here.

The executable does produce results when I double click on it.

enter image description here Next enter image description here enter image description here enter image description here enter image description here enter image description here

Edit:

I was able to locate the file after running a search where it is saving the output. The executable python is in desktop but for some reason it is saving the output of the executable in system 32 folder in c:. Why is it doing that? Since if i double click on the python executable which is on the desktop it would create a folder and files inside there but the scheduler is saving it in system 32.

Slartibartfast
  • 1,058
  • 4
  • 26
  • 60

1 Answers1

2

It should be one of these:

  1. The task from the task scheduler may not run from the same account as you might expect. Consider running it as root/administrator account.
  2. Consider generating the pyinstaller executable with the --uac-admin which will allow you to run the executable as the administrator

You could also debug the problem by piping the output to a file which will allow you to see the error message.

  • Could you please advise how can i pipe the output to a file? I should mention that the executable works when i double click on the file. – Slartibartfast Apr 23 '20 at 17:29
  • 1
    You could make a bat file with the contents `exec.exe > output.txt` and run the bat file from the scheduler – Vikramaditya Gaonkar Apr 23 '20 at 17:31
  • 1
    The `output.txt` was created, but in a different directory. In the scheduled task you indicate the path _of the executable file_, but not the path of the data file! Specify a full path for it. I.e.: `@echo off & START C:\Users\inderjeet\Desktop\python.exe > C:\Users\inderjeet\Desktop\output.txt` – Aacini Apr 28 '20 at 18:51
  • @newcoder. Keep the file in a common location outside the `Users` directory. Create a `C:\tmp` with full permissions to everyone and see if it can run from there? – Vikramaditya Gaonkar Apr 28 '20 at 20:24
  • @Aacini Sorry i did not add the full file name in the comment, however that is what i did as you have suggested. The file output.txt is created when the task runs but the it is empty – Slartibartfast Apr 28 '20 at 20:44
  • @VikramadityaGaonkar I had marked `run with highest privileges` and only when logged in. The history shows it is run but the script is not producing its intended result. – Slartibartfast Apr 28 '20 at 20:46
  • Something does flash on the python command screen briefly but is not registering on the output.txt – Slartibartfast Apr 28 '20 at 20:48
  • 1
    @newcoder are you building with `-w/--windowed/--noconsole`? If so, build without it. Then repeat and see if you get the output. – Legorooj May 02 '20 at 03:01
  • I had built it without it. – Slartibartfast May 02 '20 at 10:28