(* how many seconds before we remove the notice? *)
property dialog_timeout : 3
repeat
try
display dialog "In how many minutes must the computer be shutdown?" ¬
default answer ""
set the time_amount to the text returned of the result as integer
if the time_amount is greater than 0 then exit repeat
on error number error_number
if the error_number is -128 then return "user cancelled"
end try
end repeat
if the time_amount is 1 then
set the my_minuten to "minute"
else
set the my_minuten to "minutes"
end if
display dialog "The computer will be shutdown in " & time_amount & " " & ¬
my_minuten & "!" buttons {"Ok"} default button 1 giving up after dialog_timeout
delay time_amount * 60
tell application "Finder" to shut down
There is no canceling as I know, that would a nice addition...
[robg adds: 10.3 includes a scheduled shutdown in the Energy Saver prefs, though it might be easier to run this script as opposed to accessing the prefs each time...]

