Computing.Net > Forums > Windows XP > Command Parameter Batch File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Command Parameter Batch File

Reply to Message Icon

Name: jiko
Date: October 2, 2005 at 12:15:08 Pacific
OS: Windows XP 5.1.2600
CPU/Ram: Dell 3GB, 512 RAM
Comment:

I am trying to create a Command Prompt Batch file that allows you to get a directory listing for typing in the drive letter after the batch file name at the prompt. E.g. choose.bat a: would give you the directory of A:\. I would like it to do this for 3 Directories(C:\, C:\Windows, A:\) So far I have it only doing C:\.

This is what I have so far any help or suggestions would be appreciated.

@echo off
if not c==1%c goto PRINT
echo You must enter a parameter after the batch file name
Echo.
Echo.
Echo Directory of C:\, Directory of C:\Windows, Directory of A:\
goto End
:Print
dir C: /p
Echo You are in my Directory [C:\]
:End



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: October 2, 2005 at 13:46:14 Pacific
Reply:

hi

@echo off
if "%1"=="c:" set Drive=%1
if "%1"=="windows" set Drive=c:\%1
if "%1"=="a:" set Drive=%1
if "%Drive%"=="" (
echo Usage Test.bat [a:] [c:] [windows]
) else (
cd %Drive%
dir %Drive%
)
set Drive=


0

Response Number 2
Name: jiko
Date: October 2, 2005 at 17:21:42 Pacific
Reply:

Hey dtech10,

That was exactly what I was looking for. Thanks so much for the help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Command Parameter Batch File

DOS Batch file command www.computing.net/answers/windows-xp/dos-batch-file-command/145299.html

Several DOS Batch Files, Need help www.computing.net/answers/windows-xp/several-dos-batch-files-need-help/141749.html

Batch File that closes folders www.computing.net/answers/windows-xp/batch-file-that-closes-folders/168915.html