1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Dos programming

Discussion in 'DOS/Other' started by joinme, Apr 8, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. joinme

    joinme Thread Starter

    Joined:
    Apr 8, 2008
    Messages:
    3
    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.
     
  2. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    from the cmd line
    Code:
    FOR %A IN (C: H: I:) DO DIR %A
     
  3. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
    If you actually want to use the shift command, so you can specify the drives on the command line, this will do the trick:

    Code:
    @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
     
  4. joinme

    joinme Thread Starter

    Joined:
    Apr 8, 2008
    Messages:
    3
    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.
     
  5. joinme

    joinme Thread Starter

    Joined:
    Apr 8, 2008
    Messages:
    3
    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?
     
  6. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
    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).

    Code:
    @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:
    Code:
    @echo off
    for /f "usebackq" %%I in (`wmic diskdrive list ^| find /c /i "fixed"`) do set _n=%%I
    echo.%_n%
    set _n=
    HTH

    Jerry
     
  7. devil_himself

    devil_himself

    Joined:
    Apr 7, 2007
    Messages:
    4,910
    Here another way of determining fixed drives

    Code:
    @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
    
     
  8. kdagli

    kdagli

    Joined:
    Apr 15, 2008
    Messages:
    3
    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?
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/701547

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice