Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Local Reboot of NT Workstation

by slojuggler (Beadle)
on Oct 28, 2000 at 10:08 UTC ( #38912=perlquestion: print w/ replies, xml ) Need Help??
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://38912]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2016-07-24 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (221 votes). Check out past polls.