Running a program on Mediaportal exit. (1 Viewer)

CairnsFella

Portal Pro
July 24, 2008
51
1
Home Country
Hi all.

To get straight to the point. I want to run a program on exiting mediaportal (specifically imon, which I know has an option in minidisplay, but for me this doesnt work... so I'd like to ask the question generically if I may).

I read eslwhere that one solution is to run a .bat on execution of Mediaportal, as Mediaportal would prevent the remains of the .bat file from running until I exit. Not having written a bat file befoe, I looked into this... and whilst I now have a file that would run imon, and therefore am able to have one to run Mediaportal AND imon, I would like to ask.

1. How would I execute this in place of launching mediaportal, and 2.
2. are there any other, more integrated solutions.

Many thanks.



MediaPortal Version: 1.1
MediaPortal Skin: Streamed MP
Windows Version: 7 Ultimate
CPU Type: i3-530
HDD: 2 x 1TB
Memory: 4GB
Motherboard: H55M-USB3
Video Card: Intergated Intel
Video Card Driver:
Sound Card: Integrated Realtek
Sound Card AC3:
Sound Card Driver:
1. TV Card: Tiny Twin
1. TV Card Type:
1. TV Card Driver:
2. TV Card:
2. TV Card Type:
2. TV Card Driver:
3. TV Card:
3. TV Card Type:
3. TV Card Driver:
4. TV Card:
4. TV Card Type:
4. TV Card Driver:
MPEG2 Video Codec:
MPEG2 Audio Codec:
h.264 Video Codec:
Satelite/CableTV Provider:
HTPC Case: Silverstone LC16M-BR
Cooling:
Power Supply: Antec Earthwatts
Remote: Harmony 785
TV: Panasonc V10
TV - HTPC Connection: HDMI
 

Luca Brasi

MP Donator
  • Premium Supporter
  • November 14, 2007
    1,026
    119
    Home Country
    Germany Germany
    AW: Running a program on Mediaportal exit.

    Hi,

    I run Eventghost for stuff like this. In this case it just shows a osd message on my screen but you can add any command like executing an exe, bat or whatever. You have to add the task create/switch events plugin in eg to do so.

    Luca
     

    Attachments

    • 201005120818n25.jpg
      201005120818n25.jpg
      10.4 KB

    andrewNZ

    Portal Member
    March 31, 2010
    29
    0
    Dunedin
    Home Country
    New Zealand New Zealand
    So to cover the simple things first, you could just create a shortcut on the desktop, or keep the .bat file on the desktop and run it from there.

    However I gather you would like to run mediaportal when the computer starts up.
    If so the easiest way is to create your .bat file and run it from a scheduled task.

    How To Schedule Tasks in Windows 7 |

    I have found task scheduler to be a bit hit and miss sometimes.
    Some tricks I have found to get scheduled tasks to run reliably.
    Create the task.
    Create a new Action - add the file you want to run then cut the path and paste it into the "Start in" box
    So for a file C:\Batch_Files\Startup\Turtle.bat you'd end up with something like:
    Program/script "Turtle.bat" (with the quotes seems to work)
    Start in C:\Batch_Files\Startup\
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    So to cover the simple things first, you could just create a shortcut on the desktop, or keep the .bat file on the desktop and run it from there.

    However I gather you would like to run mediaportal when the computer starts up.
    If so the easiest way is to create your .bat file and run it from a scheduled task.

    How To Schedule Tasks in Windows 7 |

    I have found task scheduler to be a bit hit and miss sometimes.
    Some tricks I have found to get scheduled tasks to run reliably.
    Create the task.
    Create a new Action - add the file you want to run then cut the path and paste it into the "Start in" box
    So for a file C:\Batch_Files\Startup\Turtle.bat you'd end up with something like:
    Program/script "Turtle.bat" (with the quotes seems to work)
    Start in C:\Batch_Files\Startup\

    Why not just put the .bat into startup folder in start menu?
     

    CairnsFella

    Portal Pro
    July 24, 2008
    51
    1
    Home Country
    I must apologise to all.. I am not very profficient in these things.. but I do try.

    Here is what I have found after pulling out what little remains of my hair.

    1. The basic "bat" file approach just didnt work for me. It is as if something is "re-closing" imon. Its the same with the bat as it was using "restart frontview on exit" from the minidisplay plugin. With Mediaportal starting windowed, I can seee it start, and then close again.

    2. (well not really a step, but another scenario) Some combinations that I no longer recall restarted imon, but it always reset frontpage to "never" withiing the imon menu, meaning that imon started but frontview didnt (no matter if I set frontview to always or automatic).

    3. Maybe I am being a bit slow, but looking into scheduler, I could not see an option that worked for me.

    4. Event ghost. Well.. my first attempts really refelected my findings in point 2. I thought I had this worked out by figuring out how to add a delay, but I had the same problem of the Frontview option always being reset to "never"

    So finally, I seem to have botched together a solution.

    I set minidisplay to leave frontview running. I have then used an app called "pcsview" that I can call to kill an app via a bat file.

    I used this bat in eventghost to close (kill) imon when mediaportal starts... and obviously set eventghost to restsrt imon on mediaportal exit. Seems to work "so far" but I would still like to establish just whats wrong with my set up, or a more elegant solution if anyone has one (apologies if that sounds like I am saying suggestions to date are not elegant... Im not.. just they are not working for me unfotunatly)

    Thanks all.
     

    andrewNZ

    Portal Member
    March 31, 2010
    29
    0
    Dunedin
    Home Country
    New Zealand New Zealand
    At the end of your bat file add a new line and type in "pause" (no quotes) this way the command window will wait for you to press a key before it closes, it should/could give you an idea of what is going on. Often it will throw an error and instantly just bail out.
    Once you're done remove the pause and it'll all happen on it's own

    Also in Win7 in the bat file you can use Taskkill, Press [ctrl]+[shift]+[esc] to bring up task manager, click the process tab and find the process you want to kill.
    I use this to stop uTorrent, so replace uTorrent.exe with the name of your task and you should be good to go.
    Taskkill /IM uTorrent.exe /F

    So maybe a bat file like this: (quotes are required due to spaces in the file path)(you can remove the pause)

    Taskkill /IM IMON.exe /F
    "C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe"
    "C:\Program Files\SOUNDGRAPH\iMON\iMON.exe"
    pause
     

    CairnsFella

    Portal Pro
    July 24, 2008
    51
    1
    Home Country
    AndrewNZ,

    Gave your suggestion a try. Same as some of my previous results where it obviously tries to open imon, but then for some reason it gets shut down again? Im grasping at straws, but maybe somthing like IRSS does this (although from my understanding of the mediaportal log, it just mentions restarting imon, not closing it ?!?!)
     

    andrewNZ

    Portal Member
    March 31, 2010
    29
    0
    Dunedin
    Home Country
    New Zealand New Zealand
    ODD!

    I have read your initial post more closely, and I wonder if there is just too much going on.

    While my setup is not exactly the same, I did run that bat file and it did as it was supposed to.

    I have a Silverstone GD02-MT case, and a Harmony 785 remote.
    Setting up IMON to use the mediacenter remote and getting the correct buttons on the harmony proved to be a little tricky as they don't match up well. But it is working with no intermediate or alternative software.
    As far as frontview and minidislay go I'm afraid I have no experience.

    So a question:
    If you kill imon and then run a bat file to start it while nothing else is going on, does it start as expected?

    Another question:
    When mediaportal is started, does imon get killed or just frontview?
     

    CairnsFella

    Portal Pro
    July 24, 2008
    51
    1
    Home Country
    Andrew,

    Thanks again for your response.

    Yes.. your basic setup is pretty similar.

    I cant answer all your questions with absolute certainty at the moment as I am not at home, and I tried so many combo's that I wouldnt be sure on what did exactly what (other than what I already pasted). However, I am pretty sure that the bat file alone does start imon, and that mediaportal does kill imon AND frontview.

    As I intimated before, I do have a workaround at the moment using eventghost to kill imon on starting mediaportal (the minidisplay option being set NOT to close frontwiew).. and then eventghost to restart imon / frontview again on exit. It is as you say, ODD, as essentially with merely changing minidisplay to restart imon, I get the open and then close scenrio as explained. This is why I feel something else may be interfering? maybe IRSS ? darned if I know.

    Anyway, I will check my answers to your questions tonight.

    Thanks again.
     

    Users who are viewing this thread

    Top Bottom