There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware help please hijackthis hjt hjt log install internet internet explorer itunes javascript keyboard laptop log malware monitor network networking openoffice outlook outlook 2003 outlook express password popups problem router seo slow sound sp3 spyware startup trojan usb video virtumonde virus vista vundo windows windows xp winxp wireless youtube
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Dos programming


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
joinme's Avatar
Junior Member with 3 posts.
 
Join Date: Apr 2008
Experience: Intermediate
08-Apr-2008, 06:37 AM #1
Dos programming
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's Avatar
Distinguished Member with 12,328 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
08-Apr-2008, 10:50 PM #2
from the cmd line
Code:
FOR %A IN (C: H: I:) DO DIR %A
TheOutcaste's Avatar
Computer Specs
Senior Member with 1,538 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
09-Apr-2008, 02:00 AM #3
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:
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
__________________
Of course I know all the answers ; I just don't always match the answers to the right questions

Warning -- Windows spoken here. (Rated R for Strong Language and Violence -- When your Windows PC flies through a window, that's violent, right?)
joinme's Avatar
Junior Member with 3 posts.
 
Join Date: Apr 2008
Experience: Intermediate
10-Apr-2008, 08:55 PM #4
Thanks
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's Avatar
Junior Member with 3 posts.
 
Join Date: Apr 2008
Experience: Intermediate
10-Apr-2008, 08:58 PM #5
finding number of existing drivers
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's Avatar
Computer Specs
Senior Member with 1,538 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
10-Apr-2008, 10:42 PM #6
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
__________________
Of course I know all the answers ; I just don't always match the answers to the right questions

Warning -- Windows spoken here. (Rated R for Strong Language and Violence -- When your Windows PC flies through a window, that's violent, right?)
devil_himself's Avatar
Distinguished Member with 4,794 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
10-Apr-2008, 11:49 PM #7
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
kdagli's Avatar
Computer Specs
Junior Member with 3 posts.
 
Join Date: Apr 2008
Experience: Advanced
15-Apr-2008, 02:07 AM #8
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?

Last edited by kdagli : 15-Apr-2008 02:16 AM.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:04 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.