I've refined my script to add error checking when killing services and stopping the 950. I believe this will eliminate all but one possible timing issue so I can reduce delays in the TIMEOUT commands allowing the script to run faster.
The one remaining timing issue is with the restarting of ir.exe. If ir.exe doesn't fully start before the 950 is reactivated than the 950 will again control the remote. I'm unable to find any useful error codes for ir.exe that will prevent the script from advancing too soon. I tried to advance only if the ir.exe %errorlevel% is equal to 0 but it still restarts the 950 too soon.
If anyone is interested the task I set up to run the script after resuming is 'triggered on an event'. The event is 'Log:System, Source:Microsoft-Windows-Power-Troubleshooter, Event ID:1'.
The one remaining timing issue is with the restarting of ir.exe. If ir.exe doesn't fully start before the 950 is reactivated than the 950 will again control the remote. I'm unable to find any useful error codes for ir.exe that will prevent the script from advancing too soon. I tried to advance only if the ir.exe %errorlevel% is equal to 0 but it still restarts the 950 too soon.
Code:
[FONT=Lucida Console]
@ECHO off
cls
title IR Remote Reset - system start up
COLOR 1F
MODE con:cols=60 lines=20
ECHO.
ECHO *******************************
ECHO * Stopping IR Remote receiver *
ECHO *******************************
ECHO.
TIMEOUT 2
REM START "" "C:\program files\WinTV\ir.exe" /QUIT
START "" /min taskkill.exe /F /IM ir.exe
GOTO WAITSTART
:WAITSTART
ECHO.
ECHO * Waiting for services to start *
TIMEOUT 4
GOTO StopServices
:StopServices
ECHO.
ECHO *****************************************
ECHO * Stopping NextPVR and related services *
ECHO *****************************************
ECHO.
START "" /min taskkill.exe /F /IM NextPVR.exe
IF '%errorlevel%'=='1' TIMEOUT 5 GOTO StopServices
IF '%errorlevel%'=='0' GOTO HaupTVSRV
:HaupTVSRV
ECHO.
TIMEOUT 1
net stop "HauppaugeTVserver" 2>nul
NET START | FIND "HauppaugeTVserver" > nul
REM Errorlevel=0 for running service. 1 for a stopped service.
IF '%errorlevel%'=='0' TIMEOUT 5 GOTO HaupTVSRV
IF '%errorlevel%'=='1' GOTO NPVRSRV
:NPVRSRV
ECHO.
TIMEOUT 1
net stop "NPVR Recording Service" 2>nul
NET START | FIND "NPVR Recording Service" > nul
REM Errorlevel=0 for running service. 1 for a stopped service.
IF '%errorlevel%'=='0' TIMEOUT 5 GOTO NPVRSRV
IF '%errorlevel%'=='1' GOTO Disable950
:Disable950
ECHO.
TIMEOUT 1
ECHO ***********************************
ECHO * Disabling HVR-950Q USB TV Tuner *
ECHO ***********************************
ECHO.
devcon disable "USB\VID_2040&PID_7200"
REM Errorlevel=0 if successful. 1 if reboot is required.
IF '%errorlevel%'=='0' GOTO StartIRexe
IF '%errorlevel%'=='1' GOTO HaupTVSRV
:StartIRexe
ECHO.
TIMEOUT 2
ECHO *********************************
ECHO * Restarting IR Remote receiver *
ECHO *********************************
ECHO.
START "" /min "C:\Program Files\WinTV\ir.exe" /QUIET
ECHO * Waiting for Ir.exe to start *
TIMEOUT 5
ECHO.
ECHO *************************************
ECHO * Re-Enabling HVR-950Q USB TV Tuner *
ECHO *************************************
devcon enable "USB\VID_2040&PID_7200"
TIMEOUT 1
ECHO.
ECHO ********************************
ECHO * Restarting TV Tuner services *
ECHO ********************************
REM net start "HauppaugeTVserver"
net start "NPVR Recording Service"
ECHO.
ECHO *************************************************
ECHO * *
ECHO * IR Remote Control reset to HVR-1600 complete *
ECHO * *
ECHO *************************************************
ECHO.
[/FONT]
If anyone is interested the task I set up to run the script after resuming is 'triggered on an event'. The event is 'Log:System, Source:Microsoft-Windows-Power-Troubleshooter, Event ID:1'.