1.

Solve : Batch File IF "OS" WINNT?

Answer»

I'm trying to write a batch file for 2 different operating systems that will run via a login script.

The batch file needs to copy files from a network drive to the c:\windows\system32 directory for Windows XP machines and to c:\winnt\system32 for Windows 2000 machines.

I would also like it to run if possible. Here is what I have so far:

@echo off
IF "OS" == WINNT GOTO :inGOTW2K

:inGOTW2K
copy \\server\sys\public\inGOT\inGOTBalance.exe c:\winnt\system32\ /y
copy \\server\sys\public\inGOT\inGOTBalance.ini c:\winnt\system32\ /y
copy \\server\sys\public\inGOT\nwdir.ocx c:\winnt\system32\ /y
REGSVR32 NWDIR.OCX /s
START c:\winnt\system32\inGOTBalance

GOTO :END

ELSE

copy \\server\sys\public\inGOT\inGOTBalance.exe c:\windows\system32\ /y
copy \\server\sys\public\inGOT\inGOTBalance.ini c:\windows\system32\ /y
copy \\server\sys\public\inGOT\nwdir.ocx c:\windows\system32\ /y
REGSVR32 NWDIR.OCX /s
START c:\windows\system32\inGOTBalance

GOTO :END

:END

The problem is I don't know what dos CALLS windows XP as the operation system and both Start lines try to run.
Any help would be greatly appreciated
Options:

if EXIST c:\windows\system32\nul: goto win9x
if exist c:\winnt\system32\nul: goto winnt
echo Nonstandard install
goto error


Another more involved check:

ver > %version
if version=="Windows 98" goto win98
if version=="Windows XP" goto winxp
if version=="Windows NT" goto winnt
if version=="Windows 20" goto winnt


I've left out the truncation command to trim down the 'version' variable to the first 10 characters, but the idea is to compare the output of VER to the appropriate values.



Discussion

No Comment Found