如何在批处理文件中调用可执行文件 [英] How To Call Executable In Batch File
问题描述
我正在构建一个dos批处理文件(或命令批处理文件),如下所示:
@echo off
设置REGKEY = HKLM \Software \Adonix \X3RUNTIME \ x3v6
设置REGVAL = ADXDIR
REM查询价值。通过findstr管道它,以便找到具有该值的匹配行。只抓取令牌3和该行的其余部分。 %% b是我们感兴趣的。
设置VALUE =
/ f" tokens = 2,*" %% a in('reg query%REGKEY%/ v%REGVAL%^ | findstr%REGVAL%')do(
set myDir = %% b
)
$
%myDir%\ bin \ env.bat
adonix.exe - v
暂停
由于某些原因,此脚本在%myDir%\ bin \ env.nat行之后停止执行,我不知道为什么。
我想让它运行adonix -v行,但事实并非如此。事实上,如果你在env.bat文件之后放置一个echo,它仍然不会运行。
是否有运行env.bat文件(它只是为路径运行一堆SET命令)的方法,让它执行那些设置命令,然后运行adonix.exe吗?为什么它在env.bat之后停止运行?
谢谢,
尝试使用:
调用%myDir%\ bin \ env.bat文件
I'm building a dos batch file (or command batch file rather), which looks like this:
@echo offset REGKEY=HKLM\Software\Adonix\X3RUNTIME\x3v6
set REGVAL=ADXDIR
REM query the value. pipe it through findstr in order to find the matching line that has the value. only grab token 3 and the remainder of the line. %%b is what we are interested in here.
set VALUE=
for /f "tokens=2,*" %%a in ('reg query %REGKEY% /v %REGVAL% ^| findstr %REGVAL%') do (
set myDir=%%b
)
%myDir%\bin\env.bat
adonix.exe -v
pause
For some reason this script stops executing after the %myDir%\bin\env.nat line, I'm not sure why.
I want it to run the adonix -v line, but it doesn't. In fact, if you put an echo just after the env.bat file, it still won't run.
Is there a way to run the env.bat file (which simply runs a bunch of SET commands for paths), have it perform those set commands, then run the adonix.exe next? Why does it stop running after env.bat?
Thanks,
try using:
call %myDir%\bin\env.bat
这篇关于如何在批处理文件中调用可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!