Scheduled task executes but not calling console exe

Chetan Navale 11 Reputation points
2021-07-19T15:13:53.983+00:00

I have created an console application on my personal windows 10 laptop (having admin rights) using .Net Framework 4.5.2 which performs conversion of .csv/.xls/.xlsx file to .pdf.
Application contains configurable paths in config file and also a class to capture exceptions in a file.
I am able to run application without any issues in debug, release mode, Hence I created a task in task scheduler with settings as mentioned below
Security Options-->
* Run only when user is logged in
* Run with Highest Privileges selected
Triggers Tab-->
* Trigger: @00:00:01 everyday - After triggered, repeat every 1 minute for indefinitely.
Actions Tab-->
* Action: Start a program
* Program/Script: My exe path (D:\Release\XXXXX.exe)
* Start In: D:\Release
Conditions Tab-->
* Network: Any network selected
Settings Tab:
* Allow run on demand selected, everything else unselected

Along with this, even though my user is admin, I have added my user in local security policy--> local policies --> User rights assignment --> Log on as batch job

I have also added my user on the folder in which exe is placed (D:\Release)

Now when I execute the task manually from task scheduler, it gets executed properly but when I leave it to run every minute automatically, seems does not call exe and do nothing but when I am checking the last run it shows last minute ran time and last run result shows 0x0 (Successful).

I don't understand where is the exact issue with scheduler. I tried too many online searches, suggestions but nothing seems to be working

Can some one suggest if any other setting or step is missing.

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
323 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Timon Yang-MSFT 9,576 Reputation points
    2021-07-20T02:54:45.23+00:00

    I did what you said but did not encounter this problem. The task is executed correctly every minute.

    The code I used:

        static void Main(string[] args)  
        {  
            DirectoryInfo directory = new DirectoryInfo(@"c:\Test");  
            FileInfo[] fileInfos =  directory.GetFiles("*.xlsx");  
              
            foreach (var item in fileInfos)  
            {  
                  
                var book = new Aspose.Cells.Workbook(item.FullName);  
                // save XLSX as PDF  
                book.Save(@"c:\Test\"+item.Name+".pdf", Aspose.Cells.SaveFormat.Auto);  
            }  
          
        }  
    

    Task scheduler settings are exactly as you said.

    116122-12.png

    I’m using a desktop computer, so it won’t affect me whether I check it or not.

    Is it different on a laptop?

    Visual Studio 2019, .Net Framework 4.5.2, Windows 10 20H2.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.