Windows命令行:为什么环境变量在&之后不可用
发布时间:2020-12-13 22:31:49 所属栏目:Windows 来源:网络整理
导读:看看以下命令:为什么在?之后不能立即获得值? C:set a=C:set a=3echo %a%%a%C:echo %a%3C:set a=3echo %a%3 但是,当我这样做 C:set a=C:set a=3set a = 3包含在列出的变量中! 我需要这个我在这里学到的技巧,获取命令的退出代码甚至输出管道: Windo
看看以下命令:为什么在&?之后不能立即获得值?
C:&;set a= C:&;set a=3&echo %a% %a% C:&;echo %a% 3 C:&;set a=3&echo %a% 3 但是,当我这样做 C:&;set a= C:&;set a=3&set a = 3包含在列出的变量中! 我需要这个我在这里学到的技巧,获取命令的退出代码甚至输出管道: target: ($(command) & call echo %%^^errorlevel%% ^>$(exitcodefile)) 2>&1 | tee $(logfile) & set /p errorlevel_make=<$(exitcodefile) & exit /B %errorlevel_make% 但是errorlevel_make总是为空(带有退出代码的文件存在且包含正确的退出代码). 这是cmd中的错误吗?任何想法我能做什么? 解决方法
创建一个单独的批处理文件来解决这个问题要容易得多,因为即使对于专家来说也不是很明显.
但在你的情况下这应该工作 target: ($(command) & call echo %^^^^errorlevel% >$(exitcodefile)) 2>&1 | tee $(logfile) & set /p errorlevel_make=<$(exitcodefile) & call exit /B %^errorlevel_make% 单独的批次可能看起来像 extBatch.bat @echo off ("%~1" & call echo %%^^errorlevel%% > "%~2") 2>&1 | tee "%~3" & set /p errorlevel_make=<"%~2" exit /B %errorlevel_make% 然后,您可以从make文件启动批处理 target: extBatch.bat $(command) $(exitcodefile) $(logfile) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-runtime – 如何显示UIElement但没有UI交互(触摸,点
- microsoft-cognitive – LUIS:已添加具有相同密钥的项目
- .net – Microsoft HxS文件格式
- Windows 共享打印机
- 怎么把电脑桌面上的CAD图纸转换成BMP格式图纸?
- iis – 如何查看详细的500错误?
- Windows Server 2008系统状态备份
- windows-server-2008 – 使用Windows Server 2008的iPhone简
- windows-server-2008-r2 – 通过Powershell和WinRM启动安装
- windows – 如何停止在任务栏上显示我的应用程序?