I have a batch (actually two, one simple, one complex) file to send IR commands to a blaster for HTPC. I didn't write the batch files myself; too complex. Both channel_changing batch files have input parameters, one just {channel} (=3 numbers) and the more complex {channel} and {IRdefinition} (an IR definition file). I cannot invoke start /priority from the calling App directly (NextPVR) which is why I need to use two batches.
All I need is to run the channel_changing batches at high priority. I've tried calling the channel_changing batch from a simple starter_batch as follows:
GXPC4312H_StarterUUTX.bat
REM SET command=GXPC4312H_UUTX.bat REM SET command=GXPC4312H_Changer.bat for the complex one start "" /REALTIME /B %command% REM Simple Channel Changer Batch GXPC4312H_UUTX.bat
@echo off cd C:\users\public\NPVR\ChanChg\ set "channel=%1" set "num=-1" :loop set /a num=num+1 call set "name2=%%channel:~%num%,1%%" if defined name2 ( uutx.exe -r3 -s10 -fGXPC4312H.ir %name2% echo %name2% goto :loop ) Complex Channel Changer Batch GXPC4312H_Changer.bat
set sleep=0 set loops=5 :WAIT IF EXIST C:\Users\Public\NPVR\ChanChg\usblock.dat (GOTO PING) ELSE (GOTO CC) :PING timeout 1 set /A sleep=%sleep%+1 IF %sleep% EQU %loops% GOTO ERROR GOTO WAIT :CC ECHO wait_lock > C:\Users\Public\NPVR\ChanChg\usblock.dat set input=%1 if not "%input:~0,1%" == "" C:\Users\Public\NPVR\ChanChg\uutx.exe -r3 -s200 -f%~dp0%2 %input:~0,1% if not "%input:~1,1%" == "" C:\Users\Public\NPVR\ChanChg\uutx.exe -r3 -s200 -f%~dp0%2 %input:~1,1% if not "%input:~2,1%" == "" C:\Users\Public\NPVR\ChanChg\uutx.exe -r3 -s200 -f%~dp0%2 %input:~2,1% if not "%input:~3,1%" == "" C:\Users\Public\NPVR\ChanChg\uutx.exe -r3 -s200 -f%~dp0%2 %input:~3,1% del C:\Users\Public\NPVR\ChanChg\usblock.dat exit :ERROR ECHO %DATE% %TIME% >> C:\Users\Public\NPVR\ChanChg\changer_error.log GOTO :CC I ran the first one with from an elevated command prompt with the one {channel} argument e.g. 115
What I got was a batch file that never ended and threw lots of errors. It seemed NOT to be passing the channel number parameter across from the starter batch to the changing batch but I read they were passed across?
Error: unable to find codeName '~0,1' in codeFile 'GXPC4312H.ir' ~0,1 Error: unable to find codeName '~1,1' in codeFile 'GXPC4312H.ir' ~1,1 Error: unable to find codeName '~2,1' in codeFile 'GXPC4312H.ir' ~2,1 etc etc When I ran the second starter with the TWO arguments {channel} {IRDef.ir} e.g. 115 GXPC4312H.ir I got a simple error that
"The syntax of the command is incorrect" I'm not really sure what is going on here, as I've sort of inherited these batch files (and modified just path names and IRdef Files). Whilst I can follow the logic in them to some degree, I am struggling to troubleshoot the errors.
resources:
- start "Name" /Priority "PATH .. executable" --arguments https://www.tenforums.com/tutorials/89548-set-cpu-process-priority-applications-windows-10-a.html#option4
- I've read here to use call but I believe I need to use start as I wish to have the batch file run as high priority? Batch script stops after first call to other batch script
- I know you can alsio use wmic but I've read here not to use wmic as it is not reliable (and I am happy using the start "" /priority switch anwyay). https://superuser.com/questions/620724/changing-windows-process-priority-via-command-line?noredirect=1&lq=1
- Variable are passed from one batch file to another. How to pass variables from one batch file to another batch file?
wmicinitialises on first run. So the first time it is run on a computer it must be done by an admin. After that anyone can use it. Some classes are provided by the manufacturer so not all computers have all classes (eg battery will work on a desktop, returning nothing). WMI is part of a multi platform standard (WBEM), has been around for 2 decades, and works fine.%command%to%command% %*. This will pass on starter script arguments to the other scripts.