WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Microsoft Service Pack Checker


Question:

I wanted to create a script that scans my entire domain for the Service Pack I specify and then lists all the PC that don't have that Service Pack. Any suggestions? I would really appreciate it.

Answer:

There's a few ways to do it. If you're on a AD domain then the OS info is normally stored on the computer object. All you would have to do is query the computer accounts for that information.

Or you can use wntServerList to get a list of computers. Then RegConnect to each computer in the list and read the registry contents of some key that might tell you the service pack level. After you get that working for maybe 4 or 5 computers, add code to bullet proof it from computers being turned off, disconnected etc.

AddExtender("WWWNT34i.DLL")
;return a list of all Windows NT (either workstation or server)
servers = wntServerList("","",4096)
count = ItemCount(servers,@tab)
output = ""
For xx = 1 to count
	computer = ItemExtract(xx,servers,@tab)
	ErrorMode(@off)
	handle = RegConnect(computer, @REGMACHINE)
	ErrorMode(@cancel)
	if handle == 0
		err = LastError()
		errstr = IntControl (34, err, 0, 0, 0)
		Message(StrCat("Unable to connect to '",computer,"'"),StrCat("Error: ",err," ",errstr))
		continue
	endif
	subkeystr1 = "SOFTWARE\Microsoft\Windows NT\CurrentVersion[Productname]"
	subkeystr2 = "SOFTWARE\Microsoft\Windows NT\CurrentVersion[CSDVersion]"
	if RegExistValue(handle,subkeystr1) then prod = RegQueryValue(handle,subkeystr1)
	else prod = "*UNKNOWN*"
	if RegExistValue(handle,subkeystr1) then sp = RegQueryValue(handle,subkeystr2)
   else sp = "*UNKNOWN*"
	output = StrCat(output,@crlf,computer,@tab,prod,@tab, sp)
Next
output = StrSub(output,3,StrLen(output)-2)
Message("Service Pack Info",output)

Article ID:   W15993
File Created: 2004:03:30:15:42:08
Last Updated: 2004:03:30:15:42:08