-
Notifications
You must be signed in to change notification settings - Fork 1
/
RunAsLOU.dpr
58 lines (49 loc) · 1.13 KB
/
RunAsLOU.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
program RunAsLOU;
{$APPTYPE CONSOLE}
{$R *.res}
uses
SysUtils,
Windows,
uWtsUtils in 'uWtsUtils.pas';
function FileExists(FileName: string): Boolean;
var
hFile : THandle;
lpFindFileData : TWin32FindData;
begin
Result := False;
hFile := FindFirstFile(PChar(FileName), lpFindFileData);
if hFile <> INVALID_HANDLE_VALUE then
begin
FindClose(hFile);
Result := True;
end;
end;
var
sPath : string;
begin
try
WriteLn(ExtractFileName(ParamStr(0)) + ' [v1.0.0]' + #13#10);
if ParamCount < 1 then
begin
Writeln('*** error: you must supply the full local path to the program to run as the logged on user!');
Exit;
end;
sPath := ParamStr(1);
if not FileExists(sPath) then
begin
WriteLn('*** error: <' + sPath + '> was not found.');
Exit;
end;
if mgStartProcess(sPath, False) then
begin
WriteLn('process started successfully!');
end
else
begin
WriteLn('process did not start.');
end;
except
on E: Exception do
LogMessage(E.Classname + ': ' + E.Message);
end;
end.