-2

for /f "skip=1 tokens=1,2" %%i in ('wmic logicaldisk get caption^, drivetype') do (
  if [%%j]==[5] set cdletter=%%i
  )


echo %cdletter%

pause


if "%cdletter%"=="" (
echo Device driver not found: 'MSCD000'
echo No valid CDROM device drivers selected
) else ( 
echo MSCDEX Version 2.23
echo Copyright (C) Microsoft Corp. 1986-1993. All rights reserved.
pause
echo        "Drive %cdletter% = Driver MSCD000 unit 0"
)


I also ran a another if else like this before it and this one works fine. im not sure why this other one is not working

if "%cdletter%"=="" ( 
timeout 2 >nul
echo    No drives found, aborting installation
) else (

chcp 65001 >nul
wmic cdrom where mediatype!='unknown' get name > discinfo.txt
type discinfo.txt > discinfoutf8.txt 
rem F THIS YOU HAVE TO DO THIS BECASUE UTF 16 DOESNT WORK IN A FOR LOOP 

goto driveinfoecho
)

this just grabs the cd drive info so i can put it into a variable and use it in an echo command

1 Answers1

0

As an alternative to the advice you've received in the comments, I'd advise that you just omit the Else condition completely, and instead close the script if there is no CDROM, or one with an issue.

@Echo Off & SetLocal EnableExtensions
Set "Drive=" & For /F %%G In ('%SystemRoot%\System32\wbem\WMIC.exe Path
 Win32_CDROMDrive Where "ConfigManagerErrorCode=0" Get Drive 2^> NUL'
) Do For /F Tokens^=* %%H In ("%%G") Do Set "Drive=%%H"
If Not Defined Drive (Echo No properly working CDROM drive found
 Echo Press a key to exit . . . & Pause 1> NUL & GoTo :EOF)
Echo MSCDEX Version 2.23
Echo Copyright (C) Microsoft Corp. 1986-1993. All rights reserved.
Pause
Echo        "Drive %Drive% = Driver MSCD000 unit
Compo
  • 36,585
  • 5
  • 27
  • 39