Batch files for Autoinstall

I am trying to create an autoinstall for UltraVNC.  I am deploying it via a batchfile in login scripts in a Server 2k AD.  Here is what I have so far

Step 1.  This part works so far:
                if not exist "C:\Program Files\UltraVNC\winvnc.exe" \\file\install\autoinstalls\UltraVNC\oscheck.bat else exit
      This just checks to see if the program is installed already and moves on or exits depending if the file is there or not.

Step 2.  If it is not installed it then calls another batch file. This one I can't get to work.  It checks to see if Himem.sys is in the root of C:  and if it is, then it runs the 2K .msi and not the xp.msi
                if not exist "C:\himem.sys" call "\\file\install\autoinstalls\UltraVNC\xp\xpUltraAuto.bat" else call "\\file\install\autoinstalls\UltraVNC\Win2k\2kUltraAuto.bat"

I have created .msi files and they work fine, it's just step 2 that I need fixed.

               
LVL 7
Justin CollinsIT ManagerAsked:
Who is Participating?
 
fostejoCommented:
puter_geek,

No; that batch file above won't work as expected I'm afraid - for instance, if the Win2000 is detected, then both the Win2000 and XP installs will be called one after the other..

You'd need:

@echo off

VER |FIND "2000" >Nul
IF ERRORLEVEL 1 GOTO chkXP
echo Running on Win2000
call "\\file\install\autoinstalls\UltraVNC\Win2k\2kUltraAuto.bat"
GOTO Out

:chkXP
VER |FIND "XP" >Nul
IF ERRORLEVEL 1 GOTO unknownOS
echo Running on XP
call "\\file\install\autoinstalls\UltraVNC\xp\xpUltraAuto.bat"
GOTO Out

:UnknownOS
Echo Don't recognise this OS!
:Out


This way, only the appropriate install batch file will be called and then the calling batch file itself will go to ':Out' and terminate.

Hope that helps..
0
 
fostejoCommented:
puter_geek,

Try altering the line in step 2 to:

if not exist "C:\himem.sys" (call "\\file\install\autoinstalls\UltraVNC\xp\xpUltraAuto.bat") else (call "\\file\install\autoinstalls\UltraVNC\Win2k\2kUltraAuto.bat")

cheers,
0
 
Justin CollinsIT ManagerAuthor Commented:
Is there a better way to check for the OS than looking for a specific file in Win2k.  I know %ver% brings up the OS, could I use that somehow?

If you want I will give you the points for this question and post a new question for it.
0
 
fostejoCommented:
puter_geek,

Given the complexity of the original query, I don't think there'll be any issues in answering your follow-up without a seperate question...   ;)

The following code is an simple example of detecting the O/S a batch file is running on.

It 'pipes' the output of the VER command into the FIND command which then returns an ERRORLEVEL depending on whether the string to search for is found or not.  The ErrorLevel is 1 if the text isn't found.  The >Nul just stops the VER text appearing on the screen, it's sent into a black hole instead! ..


@echo off

VER |FIND "2000" >Nul
IF ERRORLEVEL 1 GOTO chkXP
echo Running on Win2000
GOTO Out

:chkXP
VER |FIND "XP" >Nul
IF ERRORLEVEL 1 GOTO unknownOS
echo Running on XP
GOTO Out

:UnknownOS
Echo Don't recognise this OS!
:Out

cheers,
0
 
Justin CollinsIT ManagerAuthor Commented:
I changed the names of the outs to match with what version I was installing and I had to add another OUT at the bottom is that right?  So with my batch files included it would be:

@echo off

VER |FIND "2000" >Nul
IF ERRORLEVEL 1 GOTO chkXP
echo Running on Win2000
GOTO Out2K

:chkXP
VER |FIND "XP" >Nul
IF ERRORLEVEL 1 GOTO unknownOS
echo Running on XP
GOTO OutXP

:UnknownOS
Echo Don't recognise this OS!
:Out2K (call "\\file\install\autoinstalls\UltraVNC\Win2k\2kUltraAuto.bat")
:OutXP (call "\\file\install\autoinstalls\UltraVNC\xp\xpUltraAuto.bat")
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.