0
Je lance des commandes Powershell via une invite DOS et je voudrais vérifier si Powershell est installé avant de commencer à exécuter mes commandes. Je voudrais que le script se termine si powershell n'existe pas sans montrer l'erreur réelle ci-dessous. Voici mon script:DOS Retourne ErrorLevel sans exécuter le programme
@echo off
setlocal enabledelayedexpansion
:: Check to see if Powershell is installed
powershell.exe -command {"test"} > NUL
if errorlevel 1 (
echo/Powershell is NOT Installed
EXIT
) else (
goto PSI
)
:PSI
powershell Set-ExecutionPolicy RemoteSigned
Le problème que je vais avoir est que je reçois cela comme sortie:
Powershell is NOT Installed
'powershell.exe' is not recognized as an internal or external command,
operable program or batch file.
En fait, la commande powershell ci-dessus est également erronée. Je devais utiliser powershell "Write-Output '' n '" 2> NUL –