Batch file wont run in Task Scheduler in Windows 10

Roy8399 0 Reputation points
2024-03-18T04:25:31.9366667+00:00

Hi I have batch files that runs perfectly when you right-click it and run it as Administrator in Windows 10 however when I test the batch file and run it on demand from task scheduler it does not run. Essentially the batch file kills a couple of processes and launches a MSedge in kiosk mode to a python script which displays a timetable.

It does appear to run the taskKill commands as I can see MSedge and the script terminate but it never launches msedge.

c:

cd "C:\Program Files (x86)\Microsoft\Edge\Application"

taskkill /f /im msedge.exe /T

taskkill /f /im python.exe /T

start msedge.exe --kiosk --no-first-run --remote-debugging-port=9111 --user-data-dir="C:\TEMP_DATA"

cd "C:\Program Files\Python311"

python.exe c:\data\show_timetable4.py

Troubleshooting:

I have enabled run with the highest privileges in Task Scheduler.

Given full access privileges to all the processor directory paths in the script.

The account that runs the task has full admin rights.

I have included a couple of tabs from task scheduler.

Generaltab.PNG

actiontab.PNG

Thankyou

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,601 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ian Xue 37,106 Reputation points Microsoft Vendor
    2024-03-25T09:10:07.43+00:00

    Hi Roy8399,

    Thanks for your post. Generally speaking, there are several reasons for why this problem happens:

    • Program files missing: If you have moved the program files to another path, the Task Scheduler is unable to access files thus it can’t be opened properly.
    • Wrong account status: If the account associated with the task is locked or expired, the Task Scheduler can’t be opened as well.
    • Insufficient user permissions: If the logged-in account doesn’t have proper rights, the Task Scheduler will come with this error message.
    • Password changed: If you have changed the password for the associated account while the Task Scheduler still performs with the old one, the same problem occurs.

    You can refer the following troubleshooting guide to narrow down the issue: Task Scheduler Failed to Launch? Fixed with Four Methods (minitool.com)

    Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

  2. MotoX80 33,826 Reputation points
    2024-03-26T00:32:56.9533333+00:00

    You have the task set to "Run whether the user is logged on or not". You need to use the "Run only when the user is logged on" in order to run the programs in the context of your desktop session so that the windows are visible. Otherwise it runs "in the background".

    For "background tasks" you should capture stdout and stderr to a log file so that you can review its output. My answer to this question shows an example of how to do that.

    https://learn.microsoft.com/en-us/answers/questions/971208/windows-task-scheduler-shows-error-0xe0434352

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.