首页 > 解决方案 > 使开始/优先级(在批处理文件中)工作并将参数从一个批处理文件传递到另一个批处理文件

问题描述

我有一个批处理(实际上是两个,一个简单,一个复杂)文件,用于将 IR 命令发送到 HTPC 的冲击波。我自己没有编写批处理文件;太复杂了。两个通道更改批处理文件都有输入参数,一个只有 {channel}(=3 个数字)和更复杂的 {channel} 和 {IRdefinition}(一个 IR 定义文件)。我不能直接从调用应用程序(NextPVR)调用启动/优先级,这就是我需要使用两个批次的原因。

我只需要以高优先级运行 channel_change 批次。我尝试从一个简单的 starter_batch 调用 channel_changeing 批处理,如下所示:

GXPC4312H_StarterUUTX.bat

REM
SET command=GXPC4312H_UUTX.bat
REM SET command=GXPC4312H_Changer.bat for the complex one
start "" /REALTIME /B %command%
REM

简单频道转换器批处理 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
)

复杂通道转换器批处理 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

我使用一个 {channel} 参数从提升的命令提示符运行第一个,例如 115

我得到的是一个永远不会结束并抛出很多错误的批处理文件。似乎没有将通道号参数从起始批次传递到更改批次,但我读到它们被传递了?

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

当我使用两个参数 {channel} {IRDef.ir} 例如 115 GXPC4312H.ir 运行第二个启动器时,我得到了一个简单的错误

"The syntax of the command is incorrect"

我不太确定这里发生了什么,因为我已经继承了这些批处理文件(并且只修改了路径名和 IRdef 文件)。虽然我可以在某种程度上遵循其中的逻辑,但我正在努力解决错误。

资源:

标签: windowsbatch-fileparameters

解决方案


推荐阅读