Computing.Net > Forums > Disk Operating System > Syntax for a OS 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.

Syntax for a OS batch file

Reply to Message Icon

Name: unclebyron
Date: September 23, 2002 at 11:54:17 Pacific
OS: win98
CPU/Ram: 733
Comment:

I want to copy files onto either Win9x or Win2K computers with a single batch file. The files will be copied into different locations depending on the OS. The batch file needs to identify which OS exists. I know the syntax is something like: IF EXIST c:\windows GOTO batch file lines or IF EXIST c:\winnt GOTO other batch file lines
I am looking for the exact syntax including any ":" etc. that may be needed.
Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: September 23, 2002 at 12:59:15 Pacific
Reply:

unclebyron wrote:
> I am looking for the exact syntax
> including any ":" etc. that may be
> needed.

What the hell is that supposed to mean?

You must take as base something that can be compared. In all NT systems, the %OS% variable is set by default to "Windows_NT" (no quotes), and in other systems, such as Win9x or DOS, that variable is not set by default (though the user could set it). Using that would be something like this:

if "%OS%"=="Windows_NT" goto win2K
goto win9x

Another possibility is the output from the VER command:

ver |FIND "Windows 2000" > nul
if not errorlevel=1 goto win2K
ver |FIND "Windows 9" > nul
if not errorlevel=1 goto win9x
echo Your operating system is not supported.
goto eof

Those are two possible and usual methods. I leave the choice to you.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0
Reply to Message Icon

Related Posts

See More


Dos Help how to compress files in ...



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: Syntax for a OS batch file

Email from a DOS batch file? www.computing.net/answers/dos/email-from-a-dos-batch-file/4591.html

Batch file to edit text file ? www.computing.net/answers/dos/batch-file-to-edit-text-file-/16127.html

Warm Boot Windows NT with a DOS batch file www.computing.net/answers/dos/warm-boot-windows-nt-with-a-dos-batch-file/5118.html