?
Solved

Batch files for Autoinstall

Posted on 2006-06-08
5
Medium Priority
?
449 Views
Last Modified: 2013-11-14
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.

               
0
Comment
Question by:puter_geek
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:fostejo
ID: 16863969
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
 
LVL 7

Author Comment

by:puter_geek
ID: 16864554
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
 
LVL 10

Expert Comment

by:fostejo
ID: 16865123
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
 
LVL 7

Author Comment

by:puter_geek
ID: 16874686
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
 
LVL 10

Accepted Solution

by:
fostejo earned 2000 total points
ID: 16877656
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question