Originally Posted by
sengsational 
A few MyHD users have returned after a few days away from their PC's to find that for some unexplainable reasons, MyHD hit a rough patch, and quit doing all scheduled recording. In order to decrease the chances of going multiple days in some kind of funk, you could have a daily scheduled machine restart, or like I'm going to try, just restart MyHD and MyIRC on a scheduled basis.
At this point, consider this solution "alpha" level, because I just wrote this batch file tonight, and only unit tested it. For XP, don't schedule it to run under a second account; it won't work, and test it using a program icon (not from the command line).
What it does: If MyHD is up, it does NOT do anything to MyHD. If MyHD is not up, it starts it and stops it (with a kill). After that, if it finds MyIRC, it kills it and then starts it.
Code:
@echo off
echo looking for running MyHD >> automation.log
for /f "tokens=1" %%a in ('tlist.exe ^| find /i "MyHD.exe"') do set pid=%%a
if not "%pid%"=="" GOTO ALREADYRUNNING
echo pid was blank [%pid%], so we can start and stop MyHD without harm.
echo Attempting to start MyHD >> automation.log
start "MyHD Start Stop" /D"c:\\program files\\MyHD\\" MyHD.exe
echo wait 30 seconds
ping -n 30 127.0.0.1>nul
for /f "tokens=1" %%b in ('tlist.exe ^| find /i "MyHD.exe"') do set pidb=%%b
kill.exe %pidb%
echo kill performed on MyHD pid %pidb% after momentarily running >> automation.log
GOTO NEXTSTEP
:ALREADYRUNNING
echo Do nothing since it's already running on %pid% >> automation.log
:NEXTSTEP
echo Attempting restart of MyIRC >> automation.log
for /f "tokens=1" %%c in ('tlist.exe ^| find /i "MyIRC.exe"') do set pidc=%%c
kill.exe %pidc%
start "MyIRC" /D"c:\\program files\\MyHD\\" MyIRC.exe
echo Restart of MyIRC completed. >> automation.log
I think "tlist.exe" and "kill.exe" came from the NT resource kit. If you dig around, you might find them out there somewhere.
Possible Improvement: This kills MyHD, so it doesn't get a chance to do it's writing to the registry as it closes. One of the things I noticed when my machine gets into a funk is that the past scheduled items (the ones it missed) remain in the registry. I'm hoping just starting MyHD will be enough to clear them, but I'm not sure when those missed schedules get fixed. So if I could figure out how to ask MyHD to end itself, rather than a kill, that would be optimal. I'll come back and edit this entry once I have more experience with it.
--Dale--
Edit: I just came back to my system after 2 weeks unattended...I didn't have a single missing show! YMMV.