@echo off & setlocal enableextensions
if "%1"=="" (
echo Usage: %~f0 [Device:]
goto :EOF)
set ready=true
dir %1 > "%temp%\tmp$$$.dir" 2>&1
find "The device is not ready" "%temp%\tmp$$$.dir" > nul
if %errorlevel% EQU 0 set ready=false
find "The system cannot find the path specified" "%temp%\tmp$$$.dir" > nul
if %errorlevel% EQU 0 set ready=false
if exist "%temp%\tmp$$$.dir" del "%temp%\tmp$$$.dir"
if "%ready%"=="true" echo The device %1 is ready
if "%ready%"=="false" echo The device %1 is not ready
endlocal & goto :EOF
The output might be e.g.
D:\TEST>cmdfaq a:
The device a: is not ready
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip
> DRAFT: (#53)
>
> @echo off & setlocal enableextensions
> if "%1"=="" (
> echo Usage: %~f0 [Device:]
> goto :EOF)
> set ready=true
> dir %1 > "%temp%\tmp$$$.dir" 2>&1
> find "The device is not ready" "%temp%\tmp$$$.dir" > nul
> if %errorlevel% EQU 0 set ready=false
> find "The system cannot find the path specified" "%temp%\tmp$$$.dir" > nul
> if %errorlevel% EQU 0 set ready=false
> if exist "%temp%\tmp$$$.dir" del "%temp%\tmp$$$.dir"
> if "%ready%"=="true" echo The device %1 is ready
> if "%ready%"=="false" echo The device %1 is not ready
> endlocal & goto :EOF
>
> The output might be e.g.
> D:\TEST>cmdfaq a:
> The device a: is not ready
>
> All the best, Timo
I'm not sure about using the term "Device" when it appears you mean a disk
drive of some kind. Perhaps lengthen it to "Storage device"?
Check this for a giggle
===[screen capture]===
D:\>cmdfaq con:
The device con: is ready
D:\>dir con:
Directory of \\.
File Not Found
D:\>cmdfaq com100:
The device com100: is ready
D:\>dir com100:
"com100:" is not a recognized device.
===[/screen capture]===
>DRAFT: (#53)
>
>@echo off & setlocal enableextensions
>if "%1"=="" (
>echo Usage: %~f0 [Device:]
>goto :EOF)
>set ready=true
>dir %1 > "%temp%\tmp$$$.dir" 2>&1
>find "The device is not ready" "%temp%\tmp$$$.dir" > nul
>if %errorlevel% EQU 0 set ready=false
>find "The system cannot find the path specified" "%temp%\tmp$$$.dir" > nul
>if %errorlevel% EQU 0 set ready=false
>if exist "%temp%\tmp$$$.dir" del "%temp%\tmp$$$.dir"
>if "%ready%"=="true" echo The device %1 is ready
>if "%ready%"=="false" echo The device %1 is not ready
>endlocal & goto :EOF
>
>The output might be e.g.
>D:\TEST>cmdfaq a:
>The device a: is not ready
>
Hello Timo,
depending on the os I'd use chkntfs or fsutil instead of dir.
There are some threads on this topic here and in mpwca.
--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
> I'd use chkntfs or fsutil instead of dir.
Bad idea
--
Marco
Good point.
@echo off & setlocal enableextensions
if "%1"=="" (
echo Usage: %~f0 [DiskDevice:]
goto :EOF)
for %%d in (a: b: c: d: e: f: g: h: i: j: k: l: m: n:
o: p: q: r: s: t: u: v: w: x: y: z:) do (
if /i "%%d"=="%1" goto _set)
echo Usage: %~f0 [DiskDevice:]
echo The DiskDevice must be A: - Z:
goto :EOF
:_set
set ready=true
dir %1 > "%temp%\tmp$$$.dir" 2>&1
find "The device is not ready" "%temp%\tmp$$$.dir" > nul
if %errorlevel% EQU 0 set ready=false
find "The system cannot find the path specified" "%temp%\tmp$$$.dir" > nul
if %errorlevel% EQU 0 set ready=false
if exist "%temp%\tmp$$$.dir" del "%temp%\tmp$$$.dir"
if "%ready%"=="true" echo The device %1 is ready
if "%ready%"=="false" echo The device %1 is not ready
endlocal & goto :EOF
All the best, Timo
> @echo off & setlocal enableextensions
> if "%1"=="" (
> echo Usage: %~f0 [DiskDevice:]
> goto :EOF)
A little more versatile?
@echo off & setlocal enableextensions
if "%1"=="" goto :_Usage
set DD=%1
if %DD:~0,2%==\\ goto :_set
for %%d in (a: b: c: d: e: f: g: h: i: j: k: l: m: n:
o: p: q: r: s: t: u: v: w: x: y: z:) do (
if /i "%%d"=="%1" goto _set)
:_Usage
echo Usage: %~f0 [DiskDevice:]
echo The DiskDevice must be A: - Z:
echo or a UNC path, beginning with \\
goto :EOF
:_set
dir %1 /-p > "%temp%\tmp$$$.dir" 2>&1
find "Volume" "%temp%\tmp$$$.dir" > nul
if %errorlevel% EQU 0 (set ready=true
) else (
set ready=false)
Without telling why: useless comment!
The FSUTIL and CHKNTFS utilities work only with NTFS volumes
That's interresting. Try to explain this output:
::chkntfs.cmd::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cls
chkntfs C:
@echo Errorlevel=%errorlevel%
chkntfs E:
@echo Errorlevel=%errorlevel%
chkntfs D:
@echo Errorlevel=%errorlevel%
chkntfs C:
@echo Errorlevel=%errorlevel%
chkntfs A:
@echo Errorlevel=%errorlevel%
::chkntfs.cmd::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
==screen copy==========================================================
C:\test>chkntfs C:
Der Typ des Dateisystems ist FAT.
C: ist nicht fehlerhaft.
Errorlevel=0
C:\test>chkntfs E:
Der Typ des Dateisystems ist NTFS.
E: ist nicht fehlerhaft.
Errorlevel=0
C:\test>chkntfs D:
CHKNTFS kann nicht für das CD-ROM-Laufwerk D: verwendet werden.
Errorlevel=2
C:\test>chkntfs C:
Der Typ des Dateisystems ist FAT.
C: ist nicht fehlerhaft.
Errorlevel=0
C:\test>chkntfs A:
Abfrage des Zustandes von Laufwerk A: fehlgeschlagen
Errorlevel=2
C:\test>
==screen copy==========================================================
Insert a floppy,a cd or a dvd
you get the same errorlevel
--
Marco