?
Solved

VB Script to verify video driver version and then update if it's not correct

Posted on 2011-09-14
2
Medium Priority
?
1,535 Views
Last Modified: 2013-11-08
Hello,

I am trying to create a vbscript that would check the video driver version and then update the driver if it is not the correct version. I have a few different machine models and various display adapters. It will need to verify the hardware and driver version then install the correct driver unattended. Below is the vbs that I started which will identify the video driver version and model. Where I am stuck is how to get the script to use the info to verify and then carry out the install. I also need to ensure the event is captured in the event viewer which I believe is almost complete but not sure if a failure is recorded. Can someone please help with reviewing this to see what I am missing. I can't seem to figure out how to get it to verify then install from a network location. Also how to handle other models? Do I just cut and paste the process and change the else command?

Sorry - please bear with me - but I am pretty new to vbscript and I still have ALOT to learn as you will see..Honestly, I am truly amazed I even got this far on my own. I am open to suggestions. Many Thanks!



On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_VideoController")

For Each objItem in colItems
    For Each strCapability in objItem.AcceleratorCapabilities
        Wscript.Echo "Accelerator Capability: " & strCapability
    Next
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Driver Date: " & objItem.DriverDate
    Wscript.Echo "Driver Version: " & objItem.DriverVersion
    Wscript.Echo "INF Filename: " & objItem.InfFilename
    Wscript.Echo "Installed Display Drivers: " & _
        objItem.InstalledDisplayDrivers
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
  WScript.Echo "Manufacturer: " & objItem.Manufacturer
  WScript.Echo "Model: " & objItem.Model
Next

Const EVENT_SUCCESS = 0

Set objShell = Wscript.CreateObject("Wscript.Shell")

objShell.LogEvent EVENT_SUCCESS, _
    "Video Driver Update Successfully Installed by IT."
   
Next

If driver version Is Not 8.15.10.2321 And the model =nvidia Then install (\\server\data\files\drivers\nvidia\setup.msi /qn)
Else End
0
Comment
Question by:Willing2Learn_More
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 36535290
Hi, give this a try, in which you need to change the array at the top.

Note that you must know the command to use for silent installation.

Read this bit about the array:
' In the array, specify each driver in four components, with the
' full computer model, part or all of the driver name,
' the desired driver version, and the command to run the install
arrDrivers = Array( _
      "Latitude D620", "nvidia", "8.15.10.2321", "cmd.exe \\server\share\nvidia\driver.exe -silent", _
      "Optiplex 990", "ati", "11.8", "msiexec.exe -i \\server\share\ati\driver.msi -qn -noreboot"

Regards,

Rob.
On Error Resume Next

' In the array, specify each driver in four components, with the
' full computer model, part or all of the driver name,
' the desired driver version, and the command to run the install
arrDrivers = Array( _
	"Latitude D620", "nvidia", "8.15.10.2321", "cmd.exe \\server\share\nvidia\driver.exe -silent", _
	"Optiplex 990", "ati", "11.8", "msiexec.exe -i \\server\share\ati\driver.msi -qn -noreboot"

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_VideoController")

For Each objItem in colItems
    For Each strCapability in objItem.AcceleratorCapabilities
        Wscript.Echo "Accelerator Capability: " & strCapability
    Next
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Driver Date: " & objItem.DriverDate
    Wscript.Echo "Driver Version: " & objItem.DriverVersion
    Wscript.Echo "INF Filename: " & objItem.InfFilename
    Wscript.Echo "Installed Display Drivers: " & objItem.InstalledDisplayDrivers
    WScript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID

    strDriverVersion = objItem.DriverVersion
    strName = objItem.Name
Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
	WScript.Echo "Manufacturer: " & objItem.Manufacturer
	WScript.Echo "Model: " & objItem.Model
	
	strModel = objItem.Model
Next

Const EVENT_SUCCESS = 0
Const EVENT_ERROR = 1

Set objShell = CreateObject("Wscript.Shell")

strCommand = ""
For i = 0 To UBound(arrDrivers) - 3 Step 4
	If LCase(strModel) = LCase(arrDrivers(i)) Then
		If InStr(LCase(strName), LCase(arrDrivers(i + 1)) > 0 Then
			If strDriverVersion <> arrDrivers(i + 2) Then
				strCommand = arrDrivers(i + 3)
				Exit For
			End If
		End If
	End If
Next

If strCommand <> "" Then
	intReturn = objShell.Run strCommand, 0, True
	If intReturn = 0 Then
		objShell.LogEvent EVENT_SUCCESS, "Video Driver Update Successfully Installed by IT."
	Else
		objShell.LogEvent EVENT_ERROR, "Video Driver Updated Failed with Return Code " & intReturn & "."
	End If
End If

Open in new window

0
 

Author Closing Comment

by:Willing2Learn_More
ID: 36546452
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

System overheating may become a serious problem if not taken care of at the proper time. I am writing this article because I faced a similar problem. Intro All electronic devices produce heat, but computers are a special case - the processors bo…
Great sound, comfort and fit, excellent build quality, versatility, compatibility. These are just some of the many reasons for choosing a headset from Sennheiser.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

770 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