[SCHEDSVC] Start jobs on timeout

- Start jobs on timeout
- Add job flags to the idl file
This commit is contained in:
Eric Kohl 2018-11-05 00:22:30 +01:00
parent 7f679a116b
commit 0d4591c672
3 changed files with 36 additions and 19 deletions

View file

@ -91,8 +91,8 @@ ReScheduleJob(
/* Remove the job from the start list */
RemoveEntryList(&pJob->StartEntry);
/* No repetition, remove the job */
if (pJob->DaysOfMonth == 0 && pJob->DaysOfWeek == 0)
/* Non-periodical job, remove it */
if ((pJob->Flags & JOB_RUN_PERIODICALLY) == 0)
{
/* Remove the job from the registry */
DeleteJob(pJob);
@ -120,12 +120,9 @@ ReScheduleJob(
VOID
RunNextJob(VOID)
{
#if 0
PROCESS_INFORMATION ProcessInformation;
STARTUPINFOW StartupInfo;
WCHAR CommandLine[256];
BOOL bRet;
#endif
PJOB pNextJob;
if (IsListEmpty(&StartListHead))
@ -136,29 +133,39 @@ RunNextJob(VOID)
pNextJob = CONTAINING_RECORD((&StartListHead)->Flink, JOB, StartEntry);
ERR("Run job %ld: %S\n", pNextJob->JobId, pNextJob->Command);
TRACE("Run job %ld: %S\n", pNextJob->JobId, pNextJob->Command);
#if 0
bRet = CreateProcess(NULL,
CommandLine,
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE | CREATE_SEPARATE_WOW_VDM,
NULL,
NULL,
&StartupInfo,
&ProcessInformation);
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpTitle = pNextJob->Command;
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow = SW_SHOWDEFAULT;
if ((pNextJob->Flags & JOB_NONINTERACTIVE) == 0)
{
StartupInfo.dwFlags |= STARTF_INHERITDESKTOP;
StartupInfo.lpDesktop = L"WinSta0\\Default";
}
bRet = CreateProcessW(NULL,
pNextJob->Command,
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&StartupInfo,
&ProcessInformation);
if (bRet == FALSE)
{
// FIXME: Log the failure!
ERR("CreateProcessW() failed (Error %lu)\n", GetLastError());
}
else
{
CloseHandle(ProcessInformation.hThread);
CloseHandle(ProcessInformation.hProcess);
}
#endif
ReScheduleJob(pNextJob);
}

View file

@ -11,6 +11,8 @@
#include <winbase.h>
#include <winreg.h>
#include <winsvc.h>
#include <winuser.h>
#include <undocuser.h>
#include <ndk/rtlfuncs.h>

View file

@ -31,6 +31,14 @@ typedef struct _AT_ENUM_CONTAINER
[size_is( EntriesRead)] LPAT_ENUM Buffer;
} AT_ENUM_CONTAINER, *PAT_ENUM_CONTAINER, *LPAT_ENUM_CONTAINER;
cpp_quote("#define JOB_RUN_PERIODICALLY 1")
cpp_quote("#define JOB_EXEC_ERROR 2")
cpp_quote("#define JOB_RUNS_TODAY 4")
cpp_quote("#define JOB_ADD_CURRENT_DATE 8")
cpp_quote("#define JOB_NONINTERACTIVE 16")
cpp_quote("#define JOB_INPUT_FLAGS (JOB_RUN_PERIODICALLY|JOB_ADD_CURRENT_DATE|JOB_NONINTERACTIVE)")
cpp_quote("#define JOB_OUTPUT_FLAGS (JOB_RUN_PERIODICALLY|JOB_EXEC_ERROR|JOB_RUNS_TODAY|JOB_NONINTERACTIVE)")
[
uuid(1FF70682-0A51-30E8-076D-740BE8CEE98B),
version(1.0),