Link to home
Start Free TrialLog in
Avatar of urif
urif

asked on

shutdown a win 2000 system

hi, is there any way to (by code) shutdown a windows system BUT with a delay? pretty much like shutdown does in Linux

something like i'd like to shutdown the machine in 10 min, so i send 10 min (or the sec.) as a parameter.

it's going to be a quick console application with no timer in it.

thanks!
Avatar of AvonWyss
AvonWyss
Flag of Switzerland image

There is, but I don't have the correct API calls at hand. However, you migh want to look at the freeware console application PSSHUTDOWN from www.sysinternals.com which does EXACTLY that - even allowing you to shutdown remote machines.
Avatar of alanwhincup
alanwhincup

If you don't want to use a timer you could just use the Sleep() function in the SysUtils unit to delay your program for a certain ammount of time. This won't allow your program to process any messages during the execution of the Sleep() function. I sometimes use the below function if i want to process messages during a delayed time period:

procedure Delay(Ms : Longint);
var
  TickCount : LongInt;
begin
  TickCount := GetTickCount;
  while GetTickCount - TickCount < Ms do
    Application.ProcessMessages;
end;
Avatar of urif

ASKER

what i'm looking for is actually how to implement the call to InitiateSystemShutdown().

i tried the code in swissdelphicenter but it just crashes (on a win2k machine running delphi 5)

any ideas on how to implement this API correctly?

thanks
ASKER CERTIFIED SOLUTION
Avatar of CrazyOne
CrazyOne
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial