Need Batch script to run windows server 2003 patch

Hello all. I am looking on how I can fix up this batch script to look for the instalation of IE and depending if it is IE 6, 7 or 8 run the different executables names below:

@echo off

IF "%1" == "" GOTO SYNTAX
IF "%2" == "" GOTO SYNTAX
IF "%3" == "" GOTO SYNTAX
goto :execute


:SYNTAX
cls
ECHO "Usage: %0 [seach criteria such as DC1 Username Password]"
GOTO EXIT

:execute
cls
title %1
Echo Generating Computer list...
dsquery computer -name %1* -limit 0 > all%1servers.txt
cls
Echo Querying computers from list...

FOR /F " tokens=2,* delims==," %%R IN (all%1servers.txt) DO psexec -c -v \\%%R WindowsServer2003-KB980182-x86-ENU.exe /quiet /norestart /log:\\%%R\admin$\%%R.log & robocopy /R:1 \\%%R\admin$\ \\DC2MS900\IE %%R.log & type \\DC2MS900\IE\%%R.log >> \\DC2MS900\IE\%0.log

:exit
----------------------
Here are the files:
If its IE 6 than run WindowsServer2003-KB980182-x86-ENU.exe
If its IE 7 than run IE7-WindowsServer2003-KB980182-x86-ENU.exe
If its IE 8 than run IE8-WindowsServer2003-KB980182-x86-ENU.exe

Thanks,
Dave
BetexAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

markdmacCommented:
Simple with vbscript
Set WSHShell = CreateObject("WScript.Shell")
strValue = WSHShell.RegRead("HKLM\Software\Microsoft\Internet Explorer\Version")
IEVer = CInt(Left(strValue, 1))

Select Case IEVer
	Case "8"
		WSHShell.Run "IE8-WindowsServer2003-KB980182-x86-ENU.exe"
	Case "7"
		WSHShell.Run "IE7-WindowsServer2003-KB980182-x86-ENU.exe"
	Case "6"
		WSHShell.Run "WindowsServer2003-KB980182-x86-ENU.exe"
End Select	

Open in new window

0
BetexAuthor Commented:
Hey Markdmac,

That almost works perfectly only thing I still will need is for this to run dsquery so that I can get a list of machines than execute the script to that list using a specific set of credential. I still need this to be logged as well in case there are machines that fail.

Thanks,
Dave
0
markdmacCommented:
Would need a lot of tweaking from my simple sample then.  You can easily switch to WMI to read a remote registry, so no big deal there, but it is the remote installation that would give you troubles then.  I'd recommend just adding this to AD in a GPO and have it log to the registry where you can then remotely read the setting with another script.  So something like this will only run the install once on a machine:


Set WSHShell = Wscript.CreateObject("Wscript.Shell")
Verify = "HKLM\SOFTWARE\MyInstallsAndFixes\" 

'Check if scan has run and if so exit
On Error Resume Next
VerifyInstall = WSHShell.RegRead(Verify & "KB980182")
If VerifyInstall = 1 Then
	WScript.Quit
Else
	'Didn't run yet so run it
	strValue = WSHShell.RegRead("HKLM\Software\Microsoft\Internet Explorer\Version")
	IEVer = CInt(Left(strValue, 1))
	
	Select Case IEVer
		Case "8"
			WSHShell.Run "IE8-WindowsServer2003-KB980182-x86-ENU.exe"
		Case "7"
			WSHShell.Run "IE7-WindowsServer2003-KB980182-x86-ENU.exe"
		Case "6"
			WSHShell.Run "WindowsServer2003-KB980182-x86-ENU.exe"
	End Select	
  'Now set the registry value to show this has completed
   WSHShell.RegWrite Verify, 1 ,"REG_DWORD"
   WSHShell.RegWrite Verify & "KB980182",1,"REG_SZ"
End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
markdmacCommented:
I want to ask, why are you having to do this?  Why not use WSUS to deploy the MS Updates.  The product is free and gives you total control over what you deploy or don't deploy in your environment.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.