slojuggler has asked for the wisdom of the Perl Monks concerning the following question:

In the spirit of Perl, instead of doing something like
system ("<friendly neighborhood shutdown.exe with args here>");
is there a relatively straightforward Perl/Perlish way of rebooting a local (i.e. the one I'm sitting at) NT workstation? That is, use Perl modules, or Perl commands to accomplish the same thing (without, of course, calling an external shutdown.exe program)? Thanks in advance!

Replies are listed 'Best First'.
Re: Local Reboot of NT Workstation
by $code or die (Deacon) on Oct 28, 2000 at 18:17 UTC
    It's in the Win32 Module as well, so this should do the trick:
    use Win32; my $machine = ""; my $message = 'WARNING: This system is about to reboot'; my $timeout = 10; # 10 seconds countdown my $forceclose = 1; # Force all applications to close without saving my $reboot = 1; # Reboot the system after shutdown Win32::InitiateSystemShutdown($machine,$message,$timeout,$forceclose,$ +reboot);
    There is also an abort call - Win32::AbortSystemShutdown($machine);

    Good Luck
(tye)Re: Local Reboot of NT Workstation
by tye (Sage) on Oct 28, 2000 at 10:57 UTC

    See InitiateSystemShutdown() in "perldoc Win32API::Registry". I'd go into more detail but I'm in a rush at the moment.

            - tye (but my friends call me "Tye")
Re: Local Reboot of NT Workstation
by gaggio (Friar) on Oct 29, 2000 at 16:42 UTC
    I prefer using Win32::AdminMisc, it is a little briefer - but in fact it is just a wrapper to the function that $code_or_die pointed out:
    Win32::AdminMisc::ExitWindows(EWX_REBOOT | EWX_FORCE);
Re: Local Reboot of NT Workstation
by slojuggler (Beadle) on Nov 01, 2000 at 21:12 UTC
    thanks everyone...i'll try this out when I have the chance.