It did not find the program already opened through the EXE running Task Scheduler

AnilkumarM 41 Reputation points
2021-09-16T02:26:41.257+00:00

I have created an EXE to find the application named “TeklaStructures” if it already opened, then to get the model details. This application I have tested by running manually is working fine. But, when it run the EXE file through the Task Scheduler, the EXE is running fine. but it is not finding the “TeklaStructures” application and will not get details even it opened already. Why it is not finding? Thanks to anyone who can assist me.

Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2021-09-17T12:02:37.883+00:00

    My EXE is not running if change the setting as you suggested.

    Why doesn't it run? What error do you get? Is that C++ code? Is it a command line program or a GUI?

    Configure the task scheduler to run a .bat file that calls your program.

    @echo Bat file starting at %date% %time%  
    C:\TheDirectoryWhereYouPutTheProgram\TheEXE.exe  /AnyArgumentThatYouPassToIt   
    @echo Program ended RC=%errorlevel%   
    @echo Bat file ending at %date% %time%  
    

    In the Task definition, configure it to run the program cmd.exe. In the arguments, you need to pass the /c switch, the name of the .bat file, and capture stdout and stderr.

    Like this

    cmd.exe /c C:\TheDirectoryWhereYouPutTheProgram\CallMyEXE.bat 1>c:\MyLogDirectory\MyEXE.log 2>&1  
    

    Here's an example of what it should look like.

    133068-capture.jpg

    After the task runs, examine the log and see what output your program produced.

    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.