Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: IF statement  (Read 2179 times)

0 Members and 1 Guest are viewing this topic.

djone21

  • Guest
IF statement
« on: February 29, 2008, 03:42:46 AM »
Hi,
I have written a script to change the optical drive attached to a computer to R: drive.  Part of the script is as follows:
Code: [Select]
::write list of dos devices from registry
ECHO DOS Devices as per Registry: >> %LOGFILE%
ECHO. >> %LOGFILE%
REG QUERY HKLM\SYSTEM\MountedDevices | FINDSTR "DosDevices" >> %LOGFILE%

::loop thru list of dos devices
FOR /F "TOKENS=1,2,3 DELIMS= " %%A IN ('REG QUERY HKLM\SYSTEM\MountedDevices ^| FINDSTR "DosDevices"') DO (
SET RAWRESULT=%%A
SET RESULT=!RAWRESULT:~26,18!

::check devices for optical drives
IF "!RESULT!"=="5C003F003F005C0049" (
  SET DLETTER=!RAWRESULT:~12,2!
  SET /A CDCOUNT=!CDCOUNT!+1
 
  ::set current drive letter into variable
  IF "!CDCOUNT!"=="1" SET CDROM1=!DLETTER!
)
)

After this has been processed, I want this to happen:
If the CDCOUNT variable is equal to 1, keep going.
If the CDCOUNT is not equal to 1 do the following:
  • "echo ERROR OPTICAL DRIVE COUNT NOT EQUAL TO 1" to command line
  • "echo ERROR OPTICAL DRIVE COUNT NOT EQUAL TO 1" >> %LOGFILE%
  • "echo OPTICAL DRIVE COUNT: echo %CDCOUNT% >> %LOGFILE%
  • "GOTO END"

any help is much appreciated :-)