Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: using TaskScheduler to reboot Win32 machine

by bmann (Priest)
on Jul 12, 2007 at 01:26 UTC ( #626123=note: print w/ replies, xml ) Need Help??


in reply to using TaskScheduler to reboot Win32 machine

The docs (Win32::TaskScheduler) say SetApplicationName expects just the name of the app. Use SetParameters for the rest, ie:

my $APP_NAME = q#c:\\perl\\bin\\perl.exe#; my $PARAMS = q#-MWin32 -e "Win32::InitiateSystemShutdown(' ','Rebootin +g',5,1,1);"#; # ... $scheduler->SetApplicationName( $APP_NAME ); $scheduler->SetParameters( $PARAMS );

Note: untested!!! now tested, parameters and command line are properly quoted.


Comment on Re: using TaskScheduler to reboot Win32 machine
Select or Download Code
Re^2: using TaskScheduler to reboot Win32 machine
by ethrbunny (Monk) on Jul 12, 2007 at 03:41 UTC
    Nice catch. That was biting me in the rear all afternoon.

    Oddly enough - it appears quoted correctly in the task scheduler but when 'run' it doesn't seem to work. It doesn't give any errors like before ("can't start", etc) though. Hmph.
      Have you checked for the last system message after the call from within Perl? That might tell if you if it's running at all and help determine the issue

      print "SysMsg - " . Win32::FormatMessage(Win32::GetLastError());

      Also, anything in the event log after you attempt the run?

      On the Windows side: I assume user/pass is a static account that will never change? Otherwise if you have a rotating password scheme for security in place, this will haunt you later in a bad way!
        backticks - `command`
        Got it working. The problem was a space in the first param to InitiateSystemShutdown. It was trying to find a machine called '<space here>' instead of the local box.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (22)
As of 2014-08-27 16:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (246 votes), past polls