Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: Marcos Lorenzo Cc: cygwin AT cygwin DOT com Subject: Re: strange error message when running SHUTDOWN.EXE as root (administrator) References: From: "Patrick J. LoPresti" Date: 06 Nov 2002 09:05:05 -0500 In-Reply-To: Message-ID: Lines: 65 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii The Perl script below should give you a better error message. Just save it as "shutdown.pl"; run it with "--help" for usage instructions. You need to run it under ActiveState Perl, not Cygwin Perl. (Unless Cygwin Perl includes the Win32API module, which I believe it does not.) - Pat # Shut down a Windows workstation. use warnings; use strict; use Getopt::Long; use Pod::Usage; use Win32API::Registry qw(:Func :SE_); # Your usual option-processing sludge. my %opts; GetOptions (\%opts, 'help|h|?', 'message=s', 'halt', 'reboot', 'timeout=i') or pod2usage (2); (exists $opts{'help'}) and pod2usage ('-exitstatus' => 0, '-verbose' => 2); # Ensure no arguments after options @ARGV == 0 or pod2usage (2); (exists $opts{'halt'} != exists $opts{'reboot'}) or die "$0: You must specify exactly one of --halt or --reboot\n"; my $timeout = (exists $opts{'timeout'} ? $opts{'timeout'} : 10); my $reboot = exists $opts{'reboot'}; my $message = (exists $opts{'message'} ? $opts{'message'} : "$0 is shutting down the system"); # Enable "shutdown" privilege AllowPriv (SE_SHUTDOWN_NAME, 1) or die "Unable to AllowPriv SE_SHUTDOWN_NAME: $^E"; InitiateSystemShutdown ('', $message, $timeout, 1, $reboot) or die "Unable to InitiateSystemShutdown: $^E"; print "Shutdown initiated.\n"; exit 0; __END__ =head1 NAME shutdown.pl - Shut down a Windows system =head1 SYNOPSIS shutdown.pl [ options ] =head1 OPTIONS --help Display help and exit --message= Display in message box during countdown --halt Shut down and halt --reboot Shut down and reboot --timeout= Wait seconds before shutdown (default 10) -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/