批处理检测系统是否安装了PowerShell
2024-12-27 乱云飞
@echo off
setlocal
:: 尝试运行powershell -command "exit" 并捕获退出代码
powershell -command "exit" >nul 2>&1
set "PSExitCode=%errorlevel%"
:: 检查退出代码
if %PSExitCode% equ 0 (
echo PowerShell 已安装。
) else (
echo PowerShell 未安装。
)
endlocal
pause本文链接:http://80c.cc/ez/801.html
发表评论: