[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Need Batch script to run windows server 2003 patch

Posted on 2010-03-31
5
Medium Priority
?
759 Views
Last Modified: 2013-11-10
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
0
Comment
Question by:Betex
  • 3
4 Comments
 
LVL 15

Expert Comment

by:markdmac
ID: 29345217
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
 

Author Comment

by:Betex
ID: 29345740
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
 
LVL 15

Accepted Solution

by:
markdmac earned 2000 total points
ID: 29347664
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
 
LVL 15

Expert Comment

by:markdmac
ID: 29347768
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Simple Linear Regression
Six Sigma Control Plans

608 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