For loop sometimes ok sometimes not ok

Microsoft Windows server 2003 enterprise
January 17, 2011 at 13:45:31
Specs: window 2003
Hi scripting guru
I would like to get all drive letters using diskpart command and for loop,
The result would be like this:
The drive letter is C
The drive letter is E
The CD-ROM is D

I create a script which seems work just for sometimes, can somebody kindly help me.....
thank you in advance

@echo off

SET OUTPUT=out.txt
SET TEMP1=1.txt
SET TEMP2=2.txt
SET TEMP3=3.txt

echo list volume > %TEMP1%
diskpart /s %TEMP1% | find "NTFS" > %TEMP2%
diskpart /s %TEMP1% | find "-ROM" > %TEMP3%

for /f "tokens=3 " %%x IN (%TEMP2%) DO echo The drive letter is %%x: >> %OUTPUT%
for /f "tokens=3,4 delims= " %%a IN (%TEMP3%) DO echo The %%b is %%a: >> %OUTPUT%

notepad out.txt
del out.txt
goto :LOOP

See More: For loop sometimes ok sometimes not ok

Report •

January 18, 2011 at 00:56:11
No idea about diskpart.

Life is too important to be taken seriously.


Report •

January 18, 2011 at 05:44:34
why not make it start %0 itself then TASKILL the previous window...

Report •
Related Solutions

Ask Question