|
Answer» 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 :-)
|