只有当第一个命令失败时,我才需要在 Windows cmd 上运行第二个命令,在另一个场景中,我想在检查是否安装后打开 python 安装程序。
我用过这个命令
python --version || path/to/python_install.exe
据我所知 || 表示如果最后一个命令失败则运行。但它只运行第一个。
Ahm*_*gdi 10
所有的评论都引导我找到了正确的方法。
我使用了这个很棒的工作代码:
:: Check for Python Installation
python --version 3>NUL
if errorlevel 1 goto errorNoPython
:: Reaching here means Python is installed.
:: Execute stuff...
:: Once done, exit the batch file -- skips executing the errorNoPython section
goto:eof
:errorNoPython
echo.
echo Error^: Python not installed
"C:\Program Files\used\systems\innoventiq\accumanager\required\excutables\python-3.7.3-amd64.exe"
Run Code Online (Sandbox Code Playgroud)
小智 5
打开命令提示符 > 键入Pytho n 或py > 按 Enter 如果安装了 Python,它将显示版本详细信息,否则它将打开 Microsoft Store 以从 Microsoft Store 下载
只需进入 cmd 并输入where python如果安装了它就会打开一个提示。
有时如果环境变量没有设置可能不行,所以你也可以通过cmd中的where python查看。如果 python 向该路径返回一些热的东西并查看 python.exe
归档时间: |
|
查看次数: |
60889 次 |
最近记录: |