1 /* $Id: init.c 13449 2005-02-06 21:55:07Z ea $
3 * initrun.c - Run all programs in the boot execution list
5 * ReactOS Operating System
7 * --------------------------------------------------------------------
9 * This software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
14 * This software is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this software; see the file COPYING.LIB. If not, write
21 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
24 * --------------------------------------------------------------------
32 HANDLE Children
[2] = {0, 0}; /* csrss, winlogon */
35 static NTSTATUS STDCALL
36 SmpRunBootAppsQueryRoutine(PWSTR ValueName
,
43 PRTL_USER_PROCESS_PARAMETERS ProcessParameters
;
44 RTL_PROCESS_INFO ProcessInfo
;
45 UNICODE_STRING ImagePathString
;
46 UNICODE_STRING CommandLineString
;
47 WCHAR Description
[256];
50 WCHAR CommandLine
[256];
55 DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName
, ValueType
, ValueLength
);
56 DPRINT("ValueData '%S'\n", (PWSTR
)ValueData
);
58 if (ValueType
!= REG_SZ
)
60 return(STATUS_SUCCESS
);
63 /* Extract the description */
64 p1
= wcschr((PWSTR
)ValueData
, L
' ');
65 len
= p1
- (PWSTR
)ValueData
;
66 memcpy(Description
,ValueData
, len
* sizeof(WCHAR
));
69 /* Extract the image name */
71 p2
= wcschr(p1
, L
' ');
76 memcpy(ImageName
, p1
, len
* sizeof(WCHAR
));
79 /* Extract the command line */
87 wcscpy(CommandLine
, p2
);
90 DPRINT("Running %S...\n", Description
);
91 DPRINT("ImageName: '%S'\n", ImageName
);
92 DPRINT("CommandLine: '%S'\n", CommandLine
);
94 /* initialize executable path */
95 wcscpy(ImagePath
, L
"\\SystemRoot\\system32\\");
96 wcscat(ImagePath
, ImageName
);
97 wcscat(ImagePath
, L
".exe");
99 RtlInitUnicodeString(&ImagePathString
,
102 RtlInitUnicodeString(&CommandLineString
,
105 RtlCreateProcessParameters(&ProcessParameters
,
116 Status
= RtlCreateUserProcess(&ImagePathString
,
117 OBJ_CASE_INSENSITIVE
,
126 if (!NT_SUCCESS(Status
))
128 DPRINT1("Running %s failed (Status %lx)\n", Description
, Status
);
129 return(STATUS_SUCCESS
);
132 RtlDestroyProcessParameters(ProcessParameters
);
134 /* Wait for process termination */
135 NtWaitForSingleObject(ProcessInfo
.ProcessHandle
,
139 NtClose(ProcessInfo
.ThreadHandle
);
140 NtClose(ProcessInfo
.ProcessHandle
);
142 return(STATUS_SUCCESS
);
147 * Run native applications listed in the registry.
150 * \Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager
152 * Value (format: "<description> <executable> <command line>":
153 * BootExecute = "autocheck autochk *"
156 SmRunBootApplications(VOID
)
158 RTL_QUERY_REGISTRY_TABLE QueryTable
[2];
161 RtlZeroMemory(&QueryTable
,
164 QueryTable
[0].Name
= L
"BootExecute";
165 QueryTable
[0].QueryRoutine
= SmpRunBootAppsQueryRoutine
;
167 Status
= RtlQueryRegistryValues(RTL_REGISTRY_CONTROL
,
168 L
"\\Session Manager",
172 if (!NT_SUCCESS(Status
))
174 DPRINT1("%s: RtlQueryRegistryValues() failed! (Status %lx)\n",