List Info

Thread: shutdown windows remotely




shutdown windows remotely
user name
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 +
     ;           ;       'Probable the "Administrator" group does not have the
"Force shutdown from a remote system" user right', mtError, [mbCancel], 0);
 ;         end;
        end;
        else begin
        ;  MessageDlg(format ('Error %d (%s) requesting reboot', [ErrorCode,
SysErrorMessage (ErrorCode)]), mtError, [mbOK], 0);
 ;       end;
      end;
    end;
  end;


kind regards,
Ronny Aerts
Belgium

----- Original Message -----
From: "eCcOns" <ecconsgmail.com&gt;
To: <delphi-en@yahoogroups.com>;
Sent: Thursday, April 06, 2006 6:33 AM
Subject: [delphi-en] shutdown windows remotely


>i have difficulty abaut shutdown windows remotely..
> can you help me or suggest site abaut that..
&gt;
> Thx
>
>
> -----------------------------------------------------
> Home page: http://groups.yahoo.com/group/delphi-en/
> To unsubscribe: delphi-en-unsubscribe@yahoogroups.com
> Yahoo! Groups Links
>;
>
&gt;
>
&gt;
>
>
>
>


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )