Computing.Net > Forums > Disk Operating System > Dos Version Branching

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 Version Branching

Reply to Message Icon

Name: Major Headache
Date: December 13, 2001 at 00:42:00 Pacific
Comment:

I'd like to be able to branch depending on whether the batch file is being run under Windows 95/98/ME (one branch) or W2k/XP (the other branch, and yes, I know those are not really DOS)

Is there a way I could do something along the lines of
"if ver == windows 95 goto b1"

I'm just winging it there, what do I REALLY do?

Another question is how to specify that the files being referenced in a batch file are in the folder from where the batch file is being run? Let me clarify with an example:
If I create a simple batch file
pack.exe myfiles.pff file1.ext
it will pack file1.ext into myfiles.pff and in this case it works prefectly as long as all those files are in the current folder. However, I'd like to be able to use some % variables, i.e.
pack.exe myfiles.pff %1
which runs the file from the defualt command prompt directory, which is not the right one.
If there was a variable who's value was "the current folder" I could do something like
cd\"the current folder"
then run the rest of the batch file.
Actually, I have a routine that does this,
%0\..\pack.exe %0\..\myfiles.pff %1
but it only works in DOS, not the CMD of 2k/XP. Is there something more direct that works in both? (in which case I wouldn't need the version branching)

Sorry if my explanation sounds confusing, hope someone can make sense out of it.



Sponsored Link
Ads by Google

Response Number 1
Name: The Doofus
Date: December 13, 2001 at 01:21:32 Pacific
Reply:

You can't launch Windows 2000\XP from a DOS batch file. Simply install Win9x first and then install Win2k\XP. Win NT will look after the dual boot for you. Or use a boot loader like XOSL.


0

Response Number 2
Name: Michael
Date: December 13, 2001 at 05:51:42 Pacific
Reply:

Whoah Doof! You totally misunderstood him. He wants to IDENTIFY which OS the batch file is running under, not use the batch to run the operating system.

You'll want to use find with ver to do what you want.

I.E.

ver | find "2000"
if %errorlevel%==0 goto 2000

ver | find "XP"
if %errorlevel%==0 goto XP

unfortunately, for whatever reason this does not work with windows 95/98/ME. Fortunately, most batches will work the same for all three of these operating systems. Just check for the existance of 2000 or XP first, then assume that it's win 95/98/ME if it's neither of those (you might want to check for NT 4.0 also depending upon the purpose of the batch).

As for your other problem, try this:

cd > currentdir.txt

This will put the current directory into that file. Then browse on over to here:
http://home7.inet.tele.dk/batfiles/main/batricks.htm#33

and it will show you how to put the contents of that text file into a variable.

Hope that helps,
Michael


0

Response Number 3
Name: The Doofus
Date: December 13, 2001 at 09:01:50 Pacific
Reply:

Ah, so I see. Well, they don't call me The Doofus for nothing. ;-)


0

Response Number 4
Name: Major Headache
Date: December 13, 2001 at 09:17:38 Pacific
Reply:

I think the firts part of that will work perfectly, thanks! Also thanks for the great link with cool tips. Takes me back a few years, lol.

The problem with the second tip is that the "current dir" is the default dir Windows kicks you out to, not necessarily the dir you're running the batch file from. I need the directory listed in %0, but in 95/98 I need the drive and filename parsed out, and in XP/2k I need that AND the surrounding quotes parsed out. (btw, tip 40 on the same page may be even more direct, but has the same problem)

Got any more great ideas?


0

Response Number 5
Name: Major Headache
Date: December 13, 2001 at 09:38:20 Pacific
Reply:

Let me ammend that. In 95/98 I can do what I've always done:
%0\..\pack.exe %0\..\myfiles.pff %1
which does everything in the current dir.

But in 2k/XP the same command translates to:
"c:\mydir"\%0\..\pack.exe etc
which doesnt work at all



0

Related Posts

See More



Response Number 6
Name: Laurence
Date: December 15, 2001 at 03:52:44 Pacific
Reply:

@ECHO off
ECHO @prompt set Version=$v$_> %temp%.\$tempA.bat
%COMSPEC% /E:4096 /c %temp%.\$tempA.bat > %temp%.\$tempB.bat
FOR %%v in (%temp%.\$tempB.bat del) do CALL %%v %temp%.\$temp?.bat
ECHO. Versions is "%Version%"


Watch for possible wrapped lines.


0

Sponsored Link
Ads by Google
Reply to Message Icon

DR-DOS 5 low level formatting



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Dos Version Branching

DOS version of Direct CD www.computing.net/answers/dos/dos-version-of-direct-cd/12388.html

I need some informtion on some DOS versions!! www.computing.net/answers/dos/i-need-some-informtion-on-some-dos-versions/1298.html

incorrect DOS version www.computing.net/answers/dos/incorrect-dos-version/7077.html