0

I called the batch file from power shell start-process "cmd.exe" "/c $createInDBs" I am trying to take input like name of the database from the command prompt using a batch file

Here is my code:

echo off
cd "C:\Program Files"
Choice /N /C ab /M "  <?> (A)Create All-in-one database   <?> (B)Create Individual database"
If Errorlevel 2 (
    set /p sIndiviName=Enter the name of webserver: 
    echo %sIndiviName% is an Individual Database.
) Else (
set /p sAllName=Enter the name of  All-in-one database:
echo %sAllName% is an All-in-one Database.
pause
)

cmd.exe is asking for the name of the database, but in the command, the database is not taken

I got 'is an All-in-one Database' Name of the database is not displayed

  • 1
    See [Using “SET /P” inside an IF statement](https://stackoverflow.com/questions/17601473/using-set-p-inside-an-if-statement). – dxiv May 28 '20 at 04:38
  • You are not using `delayedexpansion` you are setting and using variables inside code blocks, so you the correct way is to `setlocal enabledelayedexpansion` and replace your variable `%`s with `!`s For instance: `echo !sAllName!` – Gerhard May 28 '20 at 06:51

0 Answers0