in reply to Re: Automatic Windows Reboot using Perl
in thread Automatic Windows Reboot using Perl

An excellent start in the right direction for me.
The WINDOZ version I am using is Windows 2000 (currentlyt testing on). This may also go on XP. ANyway what I get is exiting, not always cleanly, back to the Win2K login window. The goal is to reboot straight through no questions asked. I have posted the code below. What subtly am I missing??
#!/usr/bin/perl -w use strict; use Win32::API; Win32::API->Import( 'User32', 'BOOL ExitWindowsEx( DWORD uFlags, DWORD dwReason )', ); ExitWindowsEx('EWX_REBOOT','4');
Your help is greatly appreciated! Thanks!

Replies are listed 'Best First'.
Re^3: Automatic Windows Reboot using Perl
by arden (Curate) on Jul 01, 2004 at 02:08 UTC
    Although I agree with the other posters in that if all you want is to reboot the computer you should just use shutdown.exe, if you need a Perl solution (say for the end of a Perl script in which you desire a reboot), this is what I use:

    Win32::InitiateSystemShutdown( '', "\nAction Complete.\n\nSystem will now Reboot\!", 20, 0, 1 );

    - - arden.

      This is exactly what I am looking for! Thanks!
      As mentionedby others, "run shutdown.exe", I was unable to find shutdown.exe on any WIN2K box that I have encountered.
      So.... the Win32::InitiateSystemShutdown routine works perfectly!
Re^3: Automatic Windows Reboot using Perl
by bunnyman (Hermit) on Jul 01, 2004 at 15:49 UTC
    You are passing 2 strings to a function that expects 2 numbers.