1.

Solve : Connecting to a drive help?

Answer»

how do you connect to the cd/dvd drive from cmd, to copy some files for it... i need to make a batch file the atomaticly COPIES the files into a specifyed location..

Thank you for any help

TheWingsERYou FIND out the drive letter for example by looking in My Computer.


you can find your CDROM letter programmatically, ASSUMING you have only 1 drive.
here's a vbscript
CODE: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colCD = objWMIService.ExecQuery("Select * from CIM_CDROMDrive")
For each objCD in colCD
Wscript.Echo objCD.Drive
Next
save it as getCDRom.vbs or other names you fancy.
here's the batch to call it
Code: [Select]@echo off
for /F "tokens=*" %%i IN ('cscript /nologo getCDRom.vbs') do (
echo %%i
)

just with batch u can get CD/DVD ROM letter :
Code: [Select]@echo off
set sum=0
for /f "tokens=3,4" %%a in ('echo list volume ^|diskpart ^|find "ROM"') do (
set LTR=%%a
set LABEL=%%b
call :calsum
)
goto next
:calsum
call set /a sum+=1
call set LTR_%sum%=%LTR%
call set LABEL_%sum%=%LABEL%
goto :eof
:next
echo You Have [%sum%] CD/DVD-ROM
for /l %%l in (1,1,%sum%) do (
call echo.[%%l].[%%LTR_%%l%%:\] - [%%LABEL_%%l%%]
)
pause>nul



Discussion

No Comment Found