Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6161289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:27:12+00:00 2026-05-23T21:27:12+00:00

If I execute the following command in a command/dos window schtasks.exe /delete /tn MMP4CDownloadCheck

  • 0

If I execute the following command in a command/dos window

schtasks.exe /delete /tn "MMP4CDownloadCheck" /f

the result is as follows

ERROR: The specified task name "MMP4CDownloadCheck" does not exist in the system.

Is it possible to retrieve the return value(s) when running the same command from within my application (Delphi XE) using ShellExec?

I run it as follows:

AHWnd := ShellExecute(0, nil, PChar('schtasks.exe'), PChar(Params), nil, SW_HIDE);

Thank you in advance.

Regards, Pieter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:27:13+00:00Added an answer on May 23, 2026 at 9:27 pm

    Not with ShellExecute. Possibly with ShellExecuteEx or CreateProcess. You need to call GetExitCodeProcess and for that you need the handle of the created process.

    For your specific case, perhaps it’s better to avoid calling schtasks.exe and use the Task Scheduler API instead. See JclTask in the JCL.

    An example usage I’ve found in one of my old units (for Delphi 2007):

    procedure TSetupDataModule.AddDatabaseBackupTask;
    var
      FileName: WideString;
      Scheduler: ITaskScheduler;
      Task: ITask;
      TaskPersist: IPersistFile;
      TriggerIndex: Word;
      Trigger: ITaskTrigger;
      TriggerData: TTaskTrigger;
    begin
      OleCheck(CoCreateInstance(CLSID_CTaskScheduler, nil, CLSCTX_INPROC_SERVER, IID_ITaskScheduler, Scheduler));
      OleCheck(Scheduler.NewWorkItem(BackupTaskName, CLSID_CTask, IID_ITask, IUnknown(Task)));
    
      FileName := WideIncludeTrailingPathDelimiter(FDatabaseTargetDir) + BackupToolFileName;
      OleCheck(Task.SetApplicationName(PWideChar(FileName)));
    
      OleCheck(Task.SetWorkingDirectory(PWideChar(WideExcludeTrailingPathDelimiter(FDatabaseTargetDir))));
      OleCheck(Task.SetAccountInformation('', nil)); // run as local system
    
      FillChar(TriggerData, SizeOf(TriggerData), 0);
      TriggerData.cbTriggerSize := SizeOf(TriggerData);
      TriggerData.wBeginYear := YearOf(Today);
      TriggerData.wBeginMonth := MonthOf(Today);
      TriggerData.wBeginDay := DayOf(Today);
      TriggerData.wStartHour := 0;
      TriggerData.wStartMinute := 0;
      TriggerData.rgFlags := 0;
      TriggerData.TriggerType := TASK_TIME_TRIGGER_DAILY;
      TriggerData.Type_.Daily.DaysInterval := 1;
    
      OleCheck(Task.CreateTrigger(TriggerIndex, Trigger));
      OleCheck(Trigger.SetTrigger(@TriggerData));
    
      TaskPersist := Task as IPersistFile;
      OleCheck(TaskPersist.Save(nil, True));
    end;
    
    procedure TSetupDataModule.RemoveDatabaseBackupTask;
    var
      Scheduler: ITaskScheduler;
    begin
      OleCheck(CoCreateInstance(CLSID_CTaskScheduler, nil, CLSCTX_INPROC_SERVER, IID_ITaskScheduler, Scheduler));
      OleCheck(Scheduler.Delete(BackupTaskName));
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to execute the following command through C#? .\binary.exe < input
If I execute the following command alone in PostgreSQL, it will insert the result
I am getting the following error when i execute the following command: text =
When I execute the following command: svnlook changed {path} -r {rev} where {path} is
How do I execute the following shell command using the Python subprocess module? echo
If I execute the following statement: string.Compare(mun, mün, true, CultureInfo.InvariantCulture) The result is '-1',
How can I execute following command line code in an ant build file? cd
I am trying to execute the following command in irb, exec 'gcc j.cpp' but,
In my bash script, i am trying to execute following Linux command: sed -i
I try to execute following code using gcc test.c -o test.o -ldbi command. #include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.