Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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!

Comment on Local Reboot of NT Workstation
Download Code
(tye)Re: Local Reboot of NT Workstation
by tye (Cardinal) 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 $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
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 wandering the Monastery: (9)
As of 2014-12-22 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (116 votes), past polls