|
List Info
Thread: shutdown windows remotely
|
|
| shutdown windows remotely |

|
2006-04-22 14:11:56 |
|
the routine for as well local as remote shutdown.
My routine looks like:
{===================================================================}
procedure PerformReboot;
{===================================================================}
VAR ErrorCode : DWORD;
UserMsg : string;
// hToken : THandle;
begin
UserMsg := 'Reboot required because of microsoft patch ' +
PPatchSettings
(_PatchSettings.Items[grdPatches.ActiveRow-1])^.PatchID + ' installation!"';
if CompSettings.ComputerName = '' then begin
if EnablePrivilege ('SeShutdownPrivilege') = 0 then begin
MessageDlg('Unable to set the "SeShutdownPrivilege" privilege',
mtError, [mbOK], 0);
end;
end
else begin
if EnablePrivilege ('SeRemoteShutdownPrivilege') = 0 then begin
MessageDlg('Unable to set the "SeRemoteShutdownPrivilege"
privilege', mtError, [mbOK], 0);
end;
end;
if InitiateSystemShutdown (PChar (CompSettings.ComputerName),
PChar (UserMsg),
_RebootDelay,
false,
true) then begin
MessageDlg('Reboot succesfully requested over and interval of ' +
IntToStr (_RebootDelay) + ' seconds', mtInformation, [mbOK], 0);
end
else begin
ErrorCode := GetLastError;
case ErrorCode of
ERROR_ACCESS_DENIED : begin
if CompSettings.ComputerName = '' then begin
MessageDlg('You do not have enough privilege to reboot this
computer', mtError, [mbCancel], 0);
end
else begin
MessageDlg('You do not have enough privilege to reboot this
computer' + cr +
&nbs | |