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

View file

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

View file

@ -31,6 +31,14 @@ typedef struct _AT_ENUM_CONTAINER
[size_is( EntriesRead)] LPAT_ENUM Buffer; [size_is( EntriesRead)] LPAT_ENUM Buffer;
} AT_ENUM_CONTAINER, *PAT_ENUM_CONTAINER, *LPAT_ENUM_CONTAINER; } 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), uuid(1FF70682-0A51-30E8-076D-740BE8CEE98B),
version(1.0), version(1.0),