且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

批处理文件以检查是否已安装Python

更新时间:2023-11-26 21:35:28

完成注册表查询后,您的代码不会分支.不管第一个if ERRORLEVEL评估结果如何,下一步始终是进入:NOPYTHON标签.

Your code doesn't branch after the registry query is done. No matter what the first if ERRORLEVEL evaluates to, the next step is always to step into the :NOPYTHON label.

Ed:这是一个使它工作的示例.想法是添加另一个goto语句,该语句将在需要时跳过:NOPYTHON标签.

Ed: Here is an example how to make it work. The idea is to add another goto statement which will skip the :NOPYTHON label if desired.

reg query "hkcu\software\Python 2.6"  
if ERRORLEVEL 1 GOTO NOPYTHON  
goto :HASPYTHON  
:NOPYTHON  
ActivePython-2.6.4.8-win32-x86.msi  

:HASPYTHON  
reg query "hklm\SOFTWARE\ActiveState\ActivePerl\" 1>>Output_%date%_%time%.log 2>&1