[batch] IF unexpected at this time error

April 16, 2010 at 09:55:48
Specs: Windows XP
echo ... checking for existing mounts
%dism% /Get-MountedWimInfo | find "%install_mnt%"
if %errorlevel% equ 1 (
set install_mnt_found=no
echo ... install.mnt not mounted.
dir %install_mnt%\*.* /b | find /v "DuMmYDaTa" >nul && set install_mnt_clean=no || set install_mnt_clean=yes
if %install_mnt_clean%==no (
echo ... *** error: data found in unmounted location.
goto end
)
) else (
set install_mnt_found=yes
)

produces:

... checking for existing mounts
( was unexpected at this time.

any idea why? it used to be working, im not sure what i did that made it this way. ive also tried variations of the statement like
if errorlevel 1 (
if %errorlevel% == 1 (


.


See More: [batch] IF unexpected at this time error

Report •

#1
April 16, 2010 at 10:37:12
ok ive figured out the source of the problem:

dir "%install_mnt%\*.*" /b | find /v "DuMmYDaTa" >nul && set install_mnt_clean=no || set install_mnt_clean=yes

this line here tests if %install_mnt% is empty, apparently the set part isn't triggered.

.


Report •

#2
April 16, 2010 at 10:44:50
if %install_mnt_clean%==no (

had to be

if "%install_mnt_clean%"=="no" (

appears fixed for now

.


Report •

#3
April 19, 2010 at 02:26:04
-Always assume that variables will be empty one day
-Prevent using || ... it's hard to debug, hard to read, and it's inproper use of a command. The purpose of this feature is that it can be used in an IF statement, and any use outside of it, should be avoided.

Report •

Related Solutions

#4
April 19, 2010 at 08:01:24
tvc: it's inproper use of a command.
Not in CMD it ain't.

Report •

Ask Question