Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file anomaly... 1

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
I'm writing a simple batch which will detect if a network drive exists before XCOPYing files over to it. If the drive doesn't exist then a GOTO statement should lead to a "NET USE" command. Part of the batch files looks like this:-


if exist L:\ goto COPYFILES
if not exist L:\ goto GETDRIVE

:GETDRIVE
net use L: \\LAPTOP\C

etc etc etc...


This all works fine in NT4 and W2K PRO, but for some strange reason fails to work in Windows ME!! The only way I can seemingly make it work in ME is to specify a dummy filename on the L:\ drive thus:-


if exist L:\fred.txt goto COPYFILES
if not exist L:\fred.txt goto GETDRIVE


Reading the helpfiles for the IF command, it doesn't in fact make any mention of specifying a condition for a DRIVE, only ERRORLEVEL, STRING MATCH or FILENAME.

So why does it NOT work in ME? Any clues as to what I'm doing wrong please?


ROGER - GØAOZ.
 
try asking someone in the Windows Me forum. Or in one of the language forums.
 
Errorlevel is the command that tests the result of a previous call, I don't have any examples (sorry) but I reckon thats that one you want to look at, in the form IF ERRORLEVEL = 1 or something like that........

Sorry I can't be more specific, I left DOS a long, long, long time ago (so it seems)

Hope this helps


Tels

Windows 2000 Network Administrator for pint$ = 1 to 20
for pint$ = pint$ + 1
if pint$ = 20 goto HOME
next pint$
 
Suspect a difference in how 95/98/me handle it versus nt/2000 family.
But why a test this way to start with? Test for mapped drive/file and go there or fallthru and process the attachment. Ed Fair
efair@atlnet.com

Any advice I give is my best judgement based on my interpretation of the facts you supply.

Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.

 
IF EXIST L: or IF EXIST L:\ will test for a drive or directory in WinNT or Win2000 but not in DOS, Win95/98/ME.

For WinME you must use:
IF EXIST L:\NUL to test for a directory
L:\ is a directory - the root directory of drive L:

Hope this helps. Good luck.

John
 
Thanks guys, I'll check it out at the weekend... Reason for testing if drive is there, means if it ain't, then the PC (illiterate!) operator gets a clear message summat's wrong, and doesn't get a "DOS" type message which might confuse the heck out of him!

ROGER - GØAOZ.
 
Thanks JohnS9051 - it worked a treat!


ROGER - GØAOZ.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top