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.
Not with
ShellExecute. Possibly withShellExecuteExorCreateProcess. You need to callGetExitCodeProcessand for that you need the handle of the created process.For your specific case, perhaps it’s better to avoid calling
schtasks.exeand use the Task Scheduler API instead. SeeJclTaskin the JCL.An example usage I’ve found in one of my old units (for Delphi 2007):