Computing.Net > Forums > Programming > DOS Batch File Commands

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.

DOS Batch File Commands

Reply to Message Icon

Name: J.C.
Date: August 12, 2006 at 18:22:04 Pacific
OS: Win98 S.E.
CPU/Ram: 950/CPU 950MB/Ram
Product: Generic
Comment:

I need help with a DOS Batch File. I have added my batch file to a Win98 Boot Floppy. The Batch file includes a Menu. One of the Menu Choices is for copying the WinXP I386 Folder etc. to a C:\I386, Folder. What commands do I need, that will call another Menu Batch File, if there in not a WinXP Install Cd in the Cd-Rom Drive?
Below are three non-working Examples of what I have tried: {NOTE # 1: The Cd-Rom Drive is set to R: from within the Autoexec.bat of the Win98 Boot Floppy}
{NOTE # 2: The Partition Letter for Winxp is E:\, but I am testing My Batch File on Partition C:\}

...................
I have tried using R: at the beginning of the Batch File
and have tried it without using R:
then I added,

if not exist R:\Winxpsp2 call NOCD.bat
if exist R:\Winxpsp2\I386 copy R:\Winxpsp2\I386 C:\I386

if not exist R:\Winxpsp2\I386 call NOCD.bat
if exist R:\Winxpsp2\I386 copy R:\Winxpsp2\I386 C:\I386

if "%1"=="error" call NOCD.bat
............................................
The message I receive is, "Not ready reading Drive R abort, retry, fail?

Question number two:
One of the Menu Choices of My Batch File is Exit.
I have Win98 S.E. installed on Partation C:\ of the Hard Drive.
What commands do I use, that will close out the Batch File and start
Win98 S.E. without having to Reboot the Computer?

Thanks,
J.C.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 12, 2006 at 23:58:38 Pacific
Reply:

"I have tried using R: at the beginning of the Batch File
and have tried it without using R:
then I added,"

If that means a line to change drive to R: it's always a bad idea to attempt to change to a drive which may not be ready. Amd it's usually unecessary.

I don't see anything wrong with this chunk:

"if not exist R:\Winxpsp2 call NOCD.bat
if exist R:\Winxpsp2\I386 copy R:\Winxpsp2\I386 C:\I386"

or the following one.

To be a little pedantic, I would use "matching pairs" of if exist/ not

if exist x:\abc
if not exist x:\abc

That way, it's sure to be one or the other.

Assuming that does not help, you may want to precede the CALL with ECHO, so you can "see what it's doing."

example:

if exist x:\abc echo got it
if not exist x:\abc echo nope

BTW, I guess you have a line which creates c:\i386 before the COPY. I always use XCOPY:

xcopy r:\i386 c:\i386\

With the trailing backslash on the dest, it will create the dir for you. And xcopy is a better tool in any case.

HTH



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: J.C.
Date: August 13, 2006 at 17:52:46 Pacific
Reply:

Thanks for the info.

Below are the commands that will accomplish the desired results for My Batch file:

if [%1]==[] goto :xcopy
if not [%1]==[] goto :nocd
echo.

:xcopy
xcopy r:\i386 c:\i386\

:nocd
call nocd.bat
..................
I cannot figure out why the lines of command listed below will not work:

Using the commands listed below, with or without the Winxpsp2 cd in the r:\ drive, the Batch File to echos nope.
if exist r:\i386 echo got it
if not exist r:\i386 echo nope
..............
If I use the commands as listed below, with or without the Winxpsp2 cd in the
r:\ drive, the Batch File always calls the nocd.bat.
if exist r:\i386 xcopy r:\i386 c:\i386\
if not exist r:\i386 call nocd.bat
......................
If I use the command
xcopy r:\i386 c:\i386\
the Batch File will copy the r:\i386 to c:\i386
...................
If I use the lines below, with or without the cd in the cd-rom drive, the batch goes to :nocd and then it calls the nocd.bat

If exist r:\i386 Goto :xcopy
if not exist r:\i386 goto :nocd

:xcopy
xcopy r:\i386 c:\i386\

:nocd
call nocd.bat

.........................
If I use the line below, it will copy the r:\i386 to r:\i386

If exist r:\i386 Goto :xcopy

:xcopy
xcopy r:\i386 c:\i386\
..............
also, If I use the command
xcopy r:\i386 c:\i386\
the Batch File will copy the r:\i386 to c:\i386

{note: You asked about creating the c:\i386 folder......
When I posted my first help request, My Batch File did include the command "md c:\i386"}
..........................
Thanks, for your comments, suggestions and help.
J.C.


0

Response Number 3
Name: J.C.
Date: August 13, 2006 at 18:33:24 Pacific
Reply:

OPPS MY MISTAKE:
I posted wrong info.
I used My Batch File from within Windows and the commands listed below worked.
However when I booted the computer using the Win98 Boot Floppy the Batch File produced the following results.
1. With the Winxp cd in the cd-rom drive the r:\i386 was copied to c:\i386.
2. Without the Winxp cd in the cd-rom drive, the message "abort, retry, fail etc.", appeared. At that point everything stopped.
3. Also, If ir remove the below commands and add the lines that include, "if exist and if not exist, commands will not work.

if [%1]==[] goto :xcopy
if not [%1]==[] goto :nocd
echo.

:xcopy
xcopy r:\i386 c:\i386\

:nocd
call nocd.bat
..........................
J.C.


0

Response Number 4
Name: Mechanix2Go
Date: August 14, 2006 at 02:21:12 Pacific
Reply:

I'm a bit befuddled.

The only thing I can suggest is, modify this:

if not exist d:\i386 echo no i386
if exist d:\i386 echo got it

to this:

if not exist d:\i386\nul echo no i386
if exist d:\i386\nul echo got it


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 5
Name: J.C.
Date: August 14, 2006 at 11:31:40 Pacific
Reply:

Current standing:

When booting with a Win98 S.E.or Win ME Boot Floppy and then calling a Batch File with these lines of command, both, found and not found are echoed. Also, I have tried everything as suggested within the replies of my post, without success.

@echo off
if exist r:\i386 echo found
if not exist r:\i386 echo not found

........................
If I use the line below, it displays the message not ready reading etc. abort etc..

@echo off
if exist r:\i386 echo found

.......................
This line displays the message not ready reading etc. abort etc..

@echo off
if not exist r:\i386 echo not found

........................................
This line does echoes the Dir files of r:\i386

dir r:\i386
........................
This line reads and echos the contents of the r:\i386 Dir and it also echos not found

dir r:\i386
if not exist r:\i386 echo not found
.......................
Mechanix2Go,
Thanks for any help and/or suggestions,
J.C.



0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: August 14, 2006 at 11:57:49 Pacific
Reply:

"I have tried everything as suggested within the replies of my post, without success."

Does that mean you added nul?


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 7
Name: J.C.
Date: August 14, 2006 at 15:06:16 Pacific
Reply:

Yes, I tried everything.
example:
if not exist r:\i386\nul echo no i386
if exist r:\i386\nul echo got it

it displayed the .....abort, retry, fail messgae.
...........
J.C.


0

Response Number 8
Name: Mechanix2Go
Date: August 14, 2006 at 15:26:12 Pacific
Reply:

I think there's a line which can be put into config or autoexec to cause it to "auto fail" if the drive is not ready. But I can't remember or find it.

Try this:

echo a|dir r:\i386


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 9
Name: J.C.
Date: August 14, 2006 at 16:46:38 Pacific
Reply:

With the Winxpsp2 cd in the Cd-rom Drive
the line "echo a|dir r:\i386", quickly reads, scrolls and dislpays the contents of
r:\i386. Using the line without the cd in the cd-drive it displays the ....abort, retry, fail message.
......................
Since the beginning of my trying to use My Batch File:
With the cd in Drive R:\,
If I use the line: {copy or} xcopy r:\i386 c:\i386, the command always runs and copies as it is suppose to.
................
With the Winxpsp2 cd in the R:\ drive:
A couple of times when using the lines below: {note or any other text to be echoed such as " echo DUMB COMPUTER FIND THE DARN THING"} It echoed not found. If I remove the line "if not exist..........." it displays the ....abort, retry, fail message.

@echo off
if exist r:\i386\nul echo found
if not exist r:\i386\nul echo not found

..................
J.C.


0

Response Number 10
Name: Mechanix2Go
Date: August 15, 2006 at 01:19:08 Pacific
Reply:

Hi J.C.,

I'm stumped.

Maybe try a post in DOS or w9x with a subject like: "ignore abort/retry/fail on empty drive"


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 11
Name: J.C.
Date: August 15, 2006 at 18:17:14 Pacific
Reply:

Thanks for all the info and help.
J.C.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: DOS Batch File Commands

batch file command? www.computing.net/answers/programming/batch-file-command/13574.html

Simple Batch File command help www.computing.net/answers/programming/simple-batch-file-command-help/16568.html

editing dos batch file www.computing.net/answers/programming/editing-dos-batch-file/20208.html