cmd - Batch not Working (If) -


master.bat

@echo off     if !%~1! == !--instance! (         if !%~2! == !old! (             echo old instance             set /p instanceid= enter instanceid:             echo %instanceid%         )         if !%~2! == !new! (             echo new instance         )     ) else (         if !%~1! neq !--instance! (             echo bad command: unknown flag/switch %1             ) else (             if !%~2! neq !new! **(                 echo bad command: incorrect flag value %2             )         )     )    

q1 : above piece of code works fine conditions except last 1 marked (**) readbility. not able comprehend why ? running following command

master.bat --instance abc 

q2: wish change same (**) line check value 'old' (quotes clarity). how ? work

if !%~2! neq !new! or !%~2! neq !old! ( echo bad command: incorrect flag value %2 )

answer q1 : recognized going wrong, control never reaching block (**).

answer q2 : , making slight changes in code snippet above work in manner expected.

@echo off setlocal  if !%~1! == !--instance! (     if !%~2! == !old! (         echo old instance         echo %instanceid%         set /p instanceid= enter instanceid:          call describeoldec2.bat %instanceid%         echo %instanceid%     ) else (         if !%~2! == !new! (             echo new instance         ) else (             echo bad command: incorrect flag value %2         )     )    ) else (     if !%~1! neq !--instance! (         echo bad command: unknown flag/switch %1         )   endlocal 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -