# Dos programming



## joinme (Apr 8, 2008)

I got a problem in using SHIFT command for different drives: The program should accomplish as in following ways:

First it should go to drive c:
and do something with my command statement
then shift to drive d:
and do the same above thing 
again shift to drive e: and do the same thing again.

example

c:
dir
d:
dir
e:
dir
f:
dir

something like the above example but using SHIFT dos command or something else.
Thanking you for all your time and kindness to help me on this matter.


----------



## Squashman (Apr 4, 2003)

from the cmd line

```
FOR %A IN (C: H: I:) DO DIR %A
```


----------



## TheOutcaste (Aug 8, 2007)

If you actually want to use the shift command, so you can specify the drives on the command line, this will do the trick:


```
@echo off
:loop
if %1.==. goto eof
dir %1[COLOR="Red"][B]:[/B][/COLOR]
shift
goto loop
```
Note the *:* in the dir line -- this way you don't have to specify it on the command line

Name it test.bat
*test C F* will do a dir on C: and F: then exit
*test H C a* will do H, C, then A and exit
*test* will just exit


----------



## joinme (Apr 8, 2008)

Thanking you for all your time and willliness to help on my question.

I didn't have the idea the FOR command in batch can be used. However, I am so  with your replies. I would like to extend my thanks for your help once again.


----------



## joinme (Apr 8, 2008)

Can you please find a way to write a batch file or a command that help to find no of drives on the system's hard disk?


----------



## TheOutcaste (Aug 8, 2007)

This will find all drives on the system and list them. This will also find CD-ROMs, mapped network drives, and USB External/Flash drives (unless they are set to Drive A or B).


```
@echo off
setlocal enabledelayedexpansion
set _t1=CDEFGHIJKLMNOPQRSTUVWXYZ
set _t2=0
FOR /L %%I in (0,1,23) do set _t3=!_t1:~%%I,1!:\ && if exist !_t3! set /a _t2=_t2+1 && echo.!_t2! = !_t3!
:The following line is not really needed as we used setlocal
FOR /L %%I in (1,1,3) do set _t%%I=
```
This will not tell you how many physical disks there are, as an extended partition on a physical disk can contain multiple Logical drives.

If you just need to know how many physical drives there are, this will do it on XP or Vista:

```
@echo off
for /f "usebackq" %%I in (`wmic diskdrive list ^| find /c /i "fixed"`) do set _n=%%I
echo.%_n%
set _n=
```
HTH

Jerry


----------



## devil_himself (Apr 7, 2007)

Here another way of determining fixed drives


```
@echo off

fsutil fsinfo drives >C:\drives.txt
for /f "tokens=1 delims=\" %%d in ('type "C:\drives.txt" ^| find "\"') do (
      fsutil fsinfo drivetype %%d | findstr /i "Fixed"
)
del C:\drives.txt /f
```


----------



## kdagli (Apr 15, 2008)

Hello All,
First thanks in advance!
I have configured my USB as a bootable device so that I use it restore hard disk images from hidden partition. But I am wrestling this from long....... how can I boot from HDD (Vista) if I am already booted from USB. 
my menuitems in config.sys includes.
1. Restore XP.
2. Restore Vista.
3. Scan computer using Norton Antivirus.
4. Partition Magic 8.0
5. BOOT FROM HDD --- cannot this to work.
Everthing seems to work except item number# 5. I have configured one menuitem "Boot from Harddisk" in config.sys so that my computer boot from HDD even though it is already booted from USB. Not sure how to get this menuitem to work.

Any suggestions?


----------

