I have a batch script like below. I want to call this script from a terminal window (cmd)<\/code> , by running it using
powershell<\/code>
Start-Process<\/code> command (Doing this in Azure ARM Template)<\/em> .
I want to pass the
INPUT<\/code> value while calling the script, probably by using a pipe symbol.
Am I missing something? How can I achieve this (without any modifications to this batch file)<\/em> ?
@echo off
SETLOCAL EnableDelayedExpansion
set INPUT=
set /P INPUT=Type yes or no: %=%
echo[
echo actually typed %INPUT%
IF "%INPUT%"=="n" goto :CLICKEDNO
IF "%INPUT%"=="N" goto :CLICKEDNO
IF "%INPUT%"=="NO" goto :CLICKEDNO
IF "%INPUT%"=="no" goto :CLICKEDNO
IF "%INPUT%"=="No" goto :CLICKEDNO
IF "%INPUT%"=="yes" goto :CLICKEDYES
IF "%INPUT%"=="Yes" goto :CLICKEDYES
IF "%INPUT%"=="Y" goto :CLICKEDYES
IF "%INPUT%"=="y" goto :CLICKEDYES
:CLICKEDYES
echo Typed yes
goto :eof
:CLICKEDNO
echo Typed no
goto :eof
echo end of file
You do not need to do a match for each case. use if \/i<\/code> to match case insensitive, we also need to use
%1<\/code> to specify :
@echo off
echo Type Yes/no & set /P "in=%1"
if /i "%in%" == "n" goto :no
if /i "%in%" == "no" goto :no
if /i "%in%" == "y" goto :yes
if /i "%in%" == "yes" goto :yes
:yes
echo Typed yes
goto :eof
:no
echo Typed no
goto :eof
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.