home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Products
TV-Server
PowerScheduler++ test versions
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="doveman" data-source="post: 841329" data-attributes="member: 67412"><p><strong>Re: AW: Re: PowerScheduler++ shares settings</strong></p><p></p><p></p><p></p><p>OK, thanks for the info. I don't know why TVservice seems to work more often after resume with 1.2.5.10 than 1.2.5.12 then, but it's still not totally reliable, so I've amended restart.vbs (which MP uses to restart when the "Restart MP on resume" option is ticked in MP config) to also restart the TVService, so I'll just untick the "Reinitialise service" in PS++.</p><p></p><p>I'm no coder, so there might be a better/neater way of doing this but it seems to work anyway. EDIT: My first attempt had various mistakes and I've also found that TVservice doesn't need to be restarted by the script, as it get's restarted when Mediaportal starts.</p><p></p><p>[CODE]Option Explicit</p><p></p><p>' *********************************************</p><p>' This function checks if a process is running </p><p>' *********************************************</p><p>Function IsProcessRunning( strProcess )</p><p> Dim Process, strObject</p><p> IsProcessRunning = False</p><p> strObject = "winmgmts:\\.\root\cimv2"</p><p> For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )</p><p> If UCase( Process.name ) = UCase( strProcess ) Then</p><p> IsProcessRunning = True</p><p> Exit Function</p><p> End If</p><p> Next</p><p>End Function</p><p></p><p></p><p>Dim Shell, Shell2, objFolder, objFolderItem, logpath, logold, lognew, syspath, FileSys, LogFile, TmpFile, strEcho, prockill, result, process, process2</p><p></p><p>' Values taken from http://msdn.microsoft.com/en-us/library/bb774096(VS.85).aspx</p><p>Const ssfCOMMONAPPDATA = 35</p><p>Const ssfSYSTEM = 37</p><p></p><p>process = "MediaPortal"</p><p>process2 = "net start TVservice"</p><p></p><p>Set Shell = CreateObject("WScript.Shell")</p><p>Set Shell2 = CreateObject("Shell.Application")</p><p>Set objFolder = Shell2.Namespace(ssfCOMMONAPPDATA)</p><p>Set objFolderItem = objFolder.Self</p><p></p><p>logpath = objFolderItem.Path & "\Team MediaPortal\MediaPortal\log\"</p><p>lognew = logpath + "\" + Wscript.ScriptName + ".log"</p><p>logold = logpath + "\" + Wscript.ScriptName + ".bak"</p><p></p><p>Set objFolder = Shell2.Namespace(ssfSYSTEM)</p><p>Set objFolderItem = objFolder.Self</p><p></p><p>syspath = objFolderItem.Path</p><p></p><p>Set FileSys = CreateObject("Scripting.FileSystemObject")</p><p>If FileSys.FileExists(lognew) Then</p><p> Set TmpFile = FileSys.GetFile(lognew)</p><p> TmpFile.Copy(logold)</p><p>End If</p><p></p><p>' Clean up for all log files to avoid confusion</p><p>If FileSys.FileExists(logpath + "\restart.log") Then</p><p> Set TmpFile = FileSys.GetFile(logpath + "\restart.log")</p><p> TmpFile.Delete</p><p>End If</p><p></p><p>Set LogFile = FileSys.CreateTextFile(lognew,1)</p><p></p><p>strEcho = Date() & "-" & Time() & ": Starting """ & Wscript.ScriptName & """ with """ & Wscript.FullName & """ (v. " & Wscript.Version & ")"</p><p>LogFile.writeline strEcho</p><p></p><p>strEcho = Date() & "-" & Time() & ": Looking for ""tskill.exe"" in """ & syspath & """"</p><p>LogFile.writeline strEcho</p><p>If FileSys.FileExists(syspath + "\tskill.exe") Then</p><p></p><p> strEcho = Date() & "-" & Time() & ": Kill utility will be ""tskill"""</p><p> LogFile.writeline strEcho</p><p> ' Using tskill to fix Mantis issue 1529</p><p> prockill = "tskill " & process</p><p></p><p>Else</p><p></p><p> strEcho = Date() & "-" & Time() & ": ""tskill.exe"" not found "</p><p> LogFile.writeline strEcho</p><p> strEcho = Date() & "-" & Time() & ": Kill utility will be ""taskkill"""</p><p> LogFile.writeline strEcho </p><p> prockill = "taskkill /F /IM " & process & ".exe"</p><p></p><p></p><p>End If</p><p></p><p>strEcho = Date() & "-" & Time() & ": Executing """ & prockill & """"</p><p>LogFile.writeline strEcho </p><p>result = Shell.Run (prockill, 0, True)</p><p>strEcho = Date() & "-" & Time() & ": Killed """ & process & """ (Exit code=" & result & ")"</p><p>LogFile.writeline strEcho </p><p>prockill = "net stop TVService"</p><p>result = Shell.Run (prockill, 0, True)</p><p>strEcho = Date() & "-" & Time() & ": Killed """ & process2 & """ (Exit code=" & result & ")"</p><p>LogFile.writeline strEcho </p><p></p><p>' Check for MediaPortal still running</p><p>do</p><p> WScript.Sleep(100)</p><p>loop while IsProcessRunning ( process & ".exe" )</p><p></p><p>strEcho = Date() & "-" & Time() & ": Executing """ & process & """"</p><p>LogFile.writeline strEcho </p><p>result = Shell.Run (process, 1, False)</p><p>strEcho = Date() & "-" & Time() & ": Started """ & process & """ (Exit code=" & result & ")" & vbcrlf</p><p>LogFile.writeline strEcho </p><p></p><p>LogFile.Close</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="doveman, post: 841329, member: 67412"] [b]Re: AW: Re: PowerScheduler++ shares settings[/b] OK, thanks for the info. I don't know why TVservice seems to work more often after resume with 1.2.5.10 than 1.2.5.12 then, but it's still not totally reliable, so I've amended restart.vbs (which MP uses to restart when the "Restart MP on resume" option is ticked in MP config) to also restart the TVService, so I'll just untick the "Reinitialise service" in PS++. I'm no coder, so there might be a better/neater way of doing this but it seems to work anyway. EDIT: My first attempt had various mistakes and I've also found that TVservice doesn't need to be restarted by the script, as it get's restarted when Mediaportal starts. [CODE]Option Explicit ' ********************************************* ' This function checks if a process is running ' ********************************************* Function IsProcessRunning( strProcess ) Dim Process, strObject IsProcessRunning = False strObject = "winmgmts:\\.\root\cimv2" For Each Process in GetObject( strObject ).InstancesOf( "win32_process" ) If UCase( Process.name ) = UCase( strProcess ) Then IsProcessRunning = True Exit Function End If Next End Function Dim Shell, Shell2, objFolder, objFolderItem, logpath, logold, lognew, syspath, FileSys, LogFile, TmpFile, strEcho, prockill, result, process, process2 ' Values taken from http://msdn.microsoft.com/en-us/library/bb774096(VS.85).aspx Const ssfCOMMONAPPDATA = 35 Const ssfSYSTEM = 37 process = "MediaPortal" process2 = "net start TVservice" Set Shell = CreateObject("WScript.Shell") Set Shell2 = CreateObject("Shell.Application") Set objFolder = Shell2.Namespace(ssfCOMMONAPPDATA) Set objFolderItem = objFolder.Self logpath = objFolderItem.Path & "\Team MediaPortal\MediaPortal\log\" lognew = logpath + "\" + Wscript.ScriptName + ".log" logold = logpath + "\" + Wscript.ScriptName + ".bak" Set objFolder = Shell2.Namespace(ssfSYSTEM) Set objFolderItem = objFolder.Self syspath = objFolderItem.Path Set FileSys = CreateObject("Scripting.FileSystemObject") If FileSys.FileExists(lognew) Then Set TmpFile = FileSys.GetFile(lognew) TmpFile.Copy(logold) End If ' Clean up for all log files to avoid confusion If FileSys.FileExists(logpath + "\restart.log") Then Set TmpFile = FileSys.GetFile(logpath + "\restart.log") TmpFile.Delete End If Set LogFile = FileSys.CreateTextFile(lognew,1) strEcho = Date() & "-" & Time() & ": Starting """ & Wscript.ScriptName & """ with """ & Wscript.FullName & """ (v. " & Wscript.Version & ")" LogFile.writeline strEcho strEcho = Date() & "-" & Time() & ": Looking for ""tskill.exe"" in """ & syspath & """" LogFile.writeline strEcho If FileSys.FileExists(syspath + "\tskill.exe") Then strEcho = Date() & "-" & Time() & ": Kill utility will be ""tskill""" LogFile.writeline strEcho ' Using tskill to fix Mantis issue 1529 prockill = "tskill " & process Else strEcho = Date() & "-" & Time() & ": ""tskill.exe"" not found " LogFile.writeline strEcho strEcho = Date() & "-" & Time() & ": Kill utility will be ""taskkill""" LogFile.writeline strEcho prockill = "taskkill /F /IM " & process & ".exe" End If strEcho = Date() & "-" & Time() & ": Executing """ & prockill & """" LogFile.writeline strEcho result = Shell.Run (prockill, 0, True) strEcho = Date() & "-" & Time() & ": Killed """ & process & """ (Exit code=" & result & ")" LogFile.writeline strEcho prockill = "net stop TVService" result = Shell.Run (prockill, 0, True) strEcho = Date() & "-" & Time() & ": Killed """ & process2 & """ (Exit code=" & result & ")" LogFile.writeline strEcho ' Check for MediaPortal still running do WScript.Sleep(100) loop while IsProcessRunning ( process & ".exe" ) strEcho = Date() & "-" & Time() & ": Executing """ & process & """" LogFile.writeline strEcho result = Shell.Run (process, 1, False) strEcho = Date() & "-" & Time() & ": Started """ & process & """ (Exit code=" & result & ")" & vbcrlf LogFile.writeline strEcho LogFile.Close [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Products
TV-Server
PowerScheduler++ test versions
Contact us
RSS
Top
Bottom