Tip - Single seat, wait for services to start before running Mediaportal (1 Viewer)

dukeelam

Portal Member
September 30, 2006
31
6
57
Home Country
Sweden Sweden
Using a single seat setup i had problems with Mediaportal autostarting too fast, resulting in it could not find the TV server when entering My TV.
I had to restart Mediaportal for it to work again, causing some irritation :)

I made the script below to wait for the SQL and TV services to start before running Mediaportal. Maybe someone else has some use for it also.

First run Mediaportal setup and uncheck the "Autostart MediaPortal when windows starts" option in "General".

Use notepad and paste the code below in to it and save as a .cmd file, for instance "startmp.cmd" .
Copy the script to your Startup folder on the Start menu.

Important: You have to edit the path between the quotes on the last line to match your Mediaportal installation directory path (Check propertys on your Mediaportal start icon and copy the path from there).


Code:
@echo off
rem script to wait for SQL Server and TV Service to start before running MediaPortal.
echo Waiting for SQL Server to start...
:NOSQL
sc query MSSQL$SQLEXPRESS | FIND "RUNNING"
if errorlevel 1 goto NOSQL
echo.
echo Waiting for TV Service to start...
:NOTVSERICE
sc query TVService | FIND "RUNNING"
if errorlevel 1 goto NOTVSERICE
echo.
echo Starting MediaPortal!
start /D"X:\THE PATH TO YOUR MEDIAPORTAL DIRECTORY" mediaportal.exe

note by infinityloop
startup delay feature has been added to mediaportal which should fix this problem ::here::
 

Hetfield

Portal Pro
March 3, 2007
69
9
Home Country
Finland Finland
I have the same problem, and I'll try this trick. But someting like this should be included in MP start up natively...
 

Hetfield

Portal Pro
March 3, 2007
69
9
Home Country
Finland Finland
Works for me, thanks. Here is batch file with some time stamp info for "debugging":

@echo off

echo Waiting for SQL Server to start: %date% %time%
:NOSQL
sc query MSSQL$SQLEXPRESS | FIND "RUNNING"
if errorlevel 1 goto NOSQL
echo SQL Server is running: %date% %time%

echo Waiting for TV Service to start: %date% %time%
:NOTVSERICE
sc query TVService | FIND "RUNNING"
if errorlevel 1 goto NOTVSERICE
echo TV Service is running: %date% %time%

echo Starting MediaPortal: %date% %time%
start C:\MediaPortal\mediaportal.exe

echo Waiting Web EPG import to be started: %date% %time%
ping 1.1.1.1 -n 120 -w 1000 >NULL
echo Starting to import Web EPG: %date% %time%
start c:\XMLTV\XMLTV.lnk
 

infinite.loop

Retired Team Member
  • Premium Supporter
  • December 26, 2004
    16,163
    4,133
    127.0.0.1
    Home Country
    Austria Austria
    "normaly" the TV-Service tries to auto-reconnect to the SQL-Service after a couple of seconds if the SQL-Server is not found.

    does that not work in your case?
     

    Hetfield

    Portal Pro
    March 3, 2007
    69
    9
    Home Country
    Finland Finland
    No it doesn't. Without this batch hack, TV will never show up before I close MP GUI with CRTL+ALT+DEL and restart it. After restart of GUI (or using this batch file) everything is OK. My quess about the problem is that the TV client has too poor error handling, or MP GUI doesn't handle the client plugin error well enough.

    See also my messages at the end of the following thread: https://forum.team-mediaportal.com/tv_service_doesnt_autostart-t22225.html?p=147120#post147120.

    This thread would maybe have been more correct place to have those writings. But in the other thread you can also find some log files, which hopefully will help you to track the problem.
     

    infinite.loop

    Retired Team Member
  • Premium Supporter
  • December 26, 2004
    16,163
    4,133
    127.0.0.1
    Home Country
    Austria Austria
    what do you mean by "MP GUI" ???
    Do you mean MediaPortal?

    what happens when you start the PC and go to "MyTV" ?
     

    Hetfield

    Portal Pro
    March 3, 2007
    69
    9
    Home Country
    Finland Finland
    I mean MediaPortal.exe. When I start MediaPortal and go to My TV, the TV will never appear. MediaPortal hangs totally and doesn't seem to respond at all. It doesn't help even if I wait 30 min or more. After I once close and restart MediaPortal, everything is OK. You can find logs from the link in my previous post. The batch file in this thread solves the problem.
     

    luksmann

    Portal Pro
    November 10, 2005
    91
    2
    35
    Home Country
    Austria Austria
    I've got the same issue, but only after "waking" the htpc from standby. I always have to restart MP in order to get it work.

    When I try to enter MyTV I always get the error message "No TV-Stream found" or "No Audio/Video".
    After restarting everything works correctly...

    Greets, luksmann
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    I've got the same issue, but only after "waking" the htpc from standby. I always have to restart MP in order to get it work.

    When I try to enter MyTV I always get the error message "No TV-Stream found" or "No Audio/Video".
    After restarting everything works correctly...

    Greets, luksmann

    That's a completely different issue.
     

    Users who are viewing this thread

    Top Bottom