How to run a command on wakeup from hibernation (1 Viewer)

robbo100

Retired Team Member
  • Premium Supporter
  • May 5, 2009
    1,291
    308
    UK
    Home Country
    United Kingdom United Kingdom
    Hi there,

    I am trying to run a batch file when the computer comes out of hibernation within the tv server element of the powerscheduler plugin.

    If I look at the MP Manual it says:

    Run command before / after standby
    Gives the option to specify a file (full path needed!) that is executed before standby and after resume. This is only executed if "Reinitialize service on wakeup" is also checked.
    which I have done.

    If I hover the mouse over the text box it says that I must include "wakeup" or "standby" within the command line.


    My quesion is what should I write in that box to make it run on wakeup? The command I wish to run is simply:

    c:\example.bat

    Thanks

    Robbo100
     

    arion_p

    Retired Team Member
  • Premium Supporter
  • February 7, 2007
    3,373
    1,626
    Athens
    Home Country
    Greece Greece
    PowerScheduler will call you command both on suspend and on wake up.
    Assuming the command you configure is "c:\example.bat", on suspend it will call:
    Code:
    c:\example.bat suspend
    and on wake up it will call:
    Code:
    c:\example.bat wakeup
    So your batch file should check %1 to see if it is called as a result of a suspend or a wake up, and act accordingly. Something like this:
    Code:
    if "%1" == "suspend" goto OnSuspend
    if "%1" == "wakeup" goto OnWakeUp
    goto Done
    
    :OnSuspend
    ... do your suspend stuff ...
    goto Done
    
    :OnWakeUp
    ... do your wake up stuff ...
    goto Done
    
    ...
    
    :Done
     

    robbo100

    Retired Team Member
  • Premium Supporter
  • May 5, 2009
    1,291
    308
    UK
    Home Country
    United Kingdom United Kingdom
    Thanks arion_p, I will give it a try.

    Given what you have said, if I were to just put:

    c:\example.bat

    would mediaportal run the batch file for both suspend and wakeup or is there something in the mediaportal powerscheduler programme which expects the "suspend" or "wakeup" words to work?

    Thanks

    Robbo100
     

    arion_p

    Retired Team Member
  • Premium Supporter
  • February 7, 2007
    3,373
    1,626
    Athens
    Home Country
    Greece Greece
    You just have to put c:\example.bat. MediaPortal will run it for both supsend and resume (you cannot change that) and will append the word suspend or wakeup in the command line depending on why it is running c:\example.bat
     

    robbo100

    Retired Team Member
  • Premium Supporter
  • May 5, 2009
    1,291
    308
    UK
    Home Country
    United Kingdom United Kingdom
    MediaPortal will run it for both supsend and resume (you cannot change that) and will append the word suspend or wakeup in the command

    Oh, now I understand.

    I will try the batch file you suggested (although I think it is supposed to he "standby" rather than "suspend").

    Hoborg, thanks for the link - everything else on my system power setting is working fine right now, so I would rather not add a the suggested link - but I will if I can't get the basic MP system working.

    Cheers

    Robbo100
     

    hoborg

    Portal Pro
    June 13, 2008
    4,413
    1,644
    Nový Jičín
    Home Country
    Czech Republic Czech Republic
    robbo100
    - it is only another option, i primary created it to fix my random HTPC freeze on WakeUp caused by WinTV HVR-1300.
    There are two vbs scripts, one executed when going in to standby, second after wakeup
     

    robbo100

    Retired Team Member
  • Premium Supporter
  • May 5, 2009
    1,291
    308
    UK
    Home Country
    United Kingdom United Kingdom
    When you hover the mouse over the text box it says "standby" so there is a mistake in that text then!

    I tried the modified batch file and it did not work at all.

    It is not running for suspend or wakeup, so there must be a problem with that function.

    I think I will try hoborg's suggestion.

    Thanks both of you for your suggestions and help so-far.

    Robbo100

    Hoborg,

    I tried your solution - instant success. Thanks mate!

    Rob
     

    Users who are viewing this thread

    Top Bottom