Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple commands in a IF statement

Can you put multiple commands in a If command? What I have is looking to see if something is installed and if it is, send text to a file and change a variable. My example is lets say you want to see if edge is installed.... Set Edge=N

If  exist "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"  (
 echo Edge is installed >> C:\Temp\Message.txt
) Else (
echo Edge is Not installed >> C:\Temp\Message.txt
)

Where would I need to put the Set Edge=Y if it is installed?

like image 384
doheth Avatar asked May 17 '26 15:05

doheth


1 Answers

If  exist "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"  (
 echo Edge is installed >> C:\Temp\Message.txt
 SET "EDGE=Y"
) Else (
SET "EDGE=N"&echo Edge is Not installed >> C:\Temp\Message.txt
)

Two ways.

Within a parenthesised block, you can place any number of statements you like, all on separate lines.

OR, you can use & to place a number of commands on one line.

like image 82
Magoo Avatar answered May 19 '26 04:05

Magoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!