Creating a OS batch file
Results 1 to 3 of 3

Thread: Creating a OS batch file

  1. #1
    Join Date
    Jun 2000
    Location
    Hacienda Heights, California USA
    Posts
    39

    Creating a OS batch file

    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

  2. #2
    Join Date
    Dec 1999
    Location
    Denmark
    Posts
    2,801
    I think something like this could be used:
    =============================

    IF EXIST c:\windows GOTO os_win9x
    IF EXIST c:\winnt GOTO os_nt
    .
    REM This is where you catch an unknown system
    .
    ECHO system unknown
    GOTO the_end
    :os_win9x
    .
    . (Your win9x actions here)
    .
    .
    GOTO the_end
    :os_nt
    .
    . (your nt/W2K actions here)
    .
    :the_end

    =================================

    The only drawback here is that your systems have to be located on the C: drive and the folders be named "windows" and "winnt". If they are not, then you have to extend the IFs to accomodate for other possible locations/names. Do some experimenting and you'll probably figure it out. It IS possible to fetch this information in the registry found in newer Windows versions (Win95->), but it'll complicate matter significantly - keep it simple if possible...

    Another thing that may help you is that you can call other bat-files with a simple "CALL bat-file-name" (using path to the file) - the "subroutines/procedures" of bat-files. Program control will transfer to the bat-file in question and return to the original bat-file once execution of the instructions in the alternate bat-file has completed - this opens up some posibilities....
    Last edited by kallikru; September 23rd, 2002 at 04:10 PM.
    Karl, Denmark
    ---------
    "..and may The Force be with you - too..."

  3. #3
    Join Date
    Jun 2000
    Location
    Hacienda Heights, California USA
    Posts
    39

    Thats it!!

    Thank you very much for your help.

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
  •