小编Lil*_*ilo的帖子

使用 %ERRORLEVEL% 从批处理脚本中的子程序返回值

我一直回荡通过下面的代码我的方式,但我不能确定为什么%ERRORLEVEL%始终为零。

@echo off

set activePerl_SiteBinPath=D:\ProgramFiles\ActivePerl\site\bin
call :isInPath %activePerl_SiteBinPath% & set foundActivePerl_SiteBinPath=%ERRORLEVEL%
echo %foundActivePerl_SiteBinPath%

set blub=d:\blub
call :isInPath %blub% & set foundBlub=%ERRORLEVEL%
echo %foundBlub%
exit /b

:isInPath
::  Tests if the path stored within variable pathVar exists within %PATH%.
::
::  The result is returned as the ERRORLEVEL:
::      0 if pathVar is found in %PATH%.
::      1 if pathVar path is not found in %PATH%.
::      2 if parhVar path is missing/undefined.

:: Error checking
if …
Run Code Online (Sandbox Code Playgroud)

cmd batch-file errorlevel subroutine

1
推荐指数
1
解决办法
1300
查看次数

标签 统计

batch-file ×1

cmd ×1

errorlevel ×1

subroutine ×1