batch file
Results 1 to 6 of 6

Thread: batch file

  1. #1
    Join Date
    Oct 2000
    Location
    Australia
    Posts
    2,146

    batch file

    can someone tell the command for determing the OS version for XP, I think winnt if for both Windows 2000/xp

    eg: below

    ;REM ***** Windows NT/2000/XP *****
    ;IF OS = "winnt"
    ;WRITE "test for Vritualdr.com"
    ;#\\servername\path
    ;IF "%ERROR_LEVEL" = "1" THEN
    ;EXIT
    ;END
    ;END

  2. #2
    Nix's Avatar
    Nix is offline Aka: Nix*, NNiixx, Nix23
    Join Date
    May 2001
    Location
    Sydney, Australia
    Posts
    8,255
    Quote Originally Posted by nemesis
    ;REM ***** Windows NT/2000/XP *****
    ;IF OS = "winnt"
    ;WRITE "test for Vritualdr.com"
    ;#\\servername\path
    ;IF "%ERROR_LEVEL" = "1" THEN
    ;EXIT
    ;END
    ;END
    Line 2: Not sure you can determine the OS and if you can what the command is, but there other errors in your batch if you took the ; of the start of each line.

    Line 3: would open up the Wordpad application and then give you an error message about no being able to find a file called test for Vritualdr.com. Also if you don't want the quotes to appear then you don't need them. The line should read echo test for Virtualdr.com

    Line 4: are you trying to change the path here, I don't think it's the correct syntax

    Line 5: The variable and value don't need to be in quotes and you need to have something after the then ie if errorlevel 1 then exit

    Line 6: presumably the Exit relates to the If Then condition in line 4

    Line 7 and 8: only need one End

    Thus:
    Code:
    ;IF OS = "winnt"
    ;echo test for Virtualdr.com
    ;#\\servername\path
    ;if errorlevel 1 then exit
    ;end
    with the italicised lines still needing some modifcation and someone else more versed in batch files may come along and help.

    Also not sure why the check of errorlevel is done as you are going to exit or end regardless ?
    Last edited by Nix; September 26th, 2005 at 11:11 PM.

  3. #3
    Join Date
    Oct 2000
    Location
    Australia
    Posts
    2,146
    thanks, the ; remarks are purely for testing, as are lines 3, 4. I just needed my question answered, I think you're right, you can't determine between Win2000 and WinXP, it's ok though, I created another solution for myself, I developed an Application Object through Novell ZENworks 6.5.

    ;REM ***** Windows NT/2000/XP *****
    ;IF OS = "winnt"
    ;WRITE "test for Vritualdr.com"
    ;#\\servername\path
    ;IF "%ERROR_LEVEL" = "1" THEN
    ;EXIT
    ;END
    ;END

  4. #4
    Nix's Avatar
    Nix is offline Aka: Nix*, NNiixx, Nix23
    Join Date
    May 2001
    Location
    Sydney, Australia
    Posts
    8,255

  5. #5
    Join Date
    May 2001
    Posts
    809
    This has been solved, a little late but wouldn't the command
    ver > version.txt
    have solved the problem?

  6. #6
    Join Date
    Apr 2005
    Location
    Maryland, USA
    Posts
    17,806
    Code:
    @echo off
    :WhatOS.BAT - Are we running under DOS, Win3.x, 9x, NT, XP?
    :Begin
     if (%OS%)==(Windows_NT) goto NTorXP
     for %%x in (OPSYS windir winbootdir) do set %%x=
     if (%windir%)==() set OPSYS=DOS
     if (%OPSYS%)==() if (%winbootdir%)==() set OPSYS=Windows_3.x
     if (%OPSYS%)==() set OPSYS=Windows_9x
     if not (%OPSYS%)==(Windows_9x) goto Done
     echo set OPSYS=Windows_%%1>windows.bat
     ver>$tmp$.bat
     for %%x in (call del) do %%x $tmp$.bat
     del windows.bat
     goto Done
    :NTorXP
     ver|find "XP">nul
     if errorlevel 1 set OPSYS=%OS%
     if errorlevel 0 if not errorlevel 1 set OPSYS=Windows_XP
    :Done
     echo %OPSYS%
     for %%x in (OPSYS cmdline) do set %%x=
    :End

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •