Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need a script to upgrade my NIC drivers on all of my workstations 1

Status
Not open for further replies.

Pyro777

MIS
Jul 14, 2006
47
US
I need to setup a script to pull the computer name from a .txt file then check the workstation type and install the appropriate updated NIC drivers for each workstation. I currently have Dell GX150, GX260, GX270, GX280, GX 620 and GX745 workstations in my environment... I found a script that I am still trying to modify to examine the workstation model and then install the update seamlessly on the workstation. I am very new to scripting so any help would be much appreciated.
Here is what I have, I know I have a long way to go with this one...

Option Explicit

Dim objShell, objDictionary, objFSO, objTextFile, i, strNextLine, objItem

Const ForReading = 1

Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("H:\scriptlogs\GX260\machines.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
Loop

For Each objItem in objDictionary
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "H:\Drivers\GX260nicdrivers\dellnic.exe",7,True
Next
 
Will the script be running locally on each machine or are you looking at doing it remotely? You may be able to use WMI and the Win32_ComputerSystem class to determine the computer model.
--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
I would like to run this script remotely to check each systems model number and then install the correct NIC driver on each system.. I do know that the GX260 and GX270 use the same NIC/Driver... As I said, I am very new to scripting so I am still learning as I go...
 
For the basic design, I would find the model number using WMI and then use a select case statement to determine which driver you install.

Its not close to being ready to test but this will give you an idea how to code what you're trying to do.

Code:
 Option Explicit

Dim objShell, objDictionary, objFSO, objTextFile, i, strNextLine, objItem

Const ForReading = 1

Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("H:\scriptlogs\GX260\machines.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
 strNextLine = objTextFile.Readline
 objDictionary.Add i, strNextLine
 i = i + 1
Loop

For Each objItem in objDictionary
[b]  strcomputer = objDictionary.Item(objItem)[/b]
Set objShell = WScript.CreateObject("WScript.Shell")
[b]Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter Where IPenabled=True")


For Each objitem in colItems
    Select Case ObjItem.Name
           Case "NIC Type #1"    
           objShell.Run "H:\Driver #1"
           Case "NIC Type #2"
           objShell.Run "H:\Driver #2           
           Case "NIC Type #3"
           objShell.Run "H:\Driver #3    
Next
[/b]
 
I would stay away from using the model number of the computer. Dell uses standard NIC cards and the drivers are, for the most part, the same for each NIC type. Here is a script similiar to the one above but this one checks for the presence of an Intel 2200 or 3945 wireless adapter. They use the same driver. I made an administrative installation of the Intel ProSet to the latest version (10.5.1.0 right now). You could easily modify it. My script will also e-mail me if it fails.

Sub IntelWireless()

on error resume next
Set filesys = CreateObject("Scripting.FileSystemObject")
Set ProgFiles = WScript.CreateObject ("WScript.Shell")
Set WshShell = WScript.CreateObject ("WScript.Shell")

MajVer = 10
MinVer = 5
Build = 1
baseInstall = "\\filesrv01\sms$\Intel Proset 10.5.1\IntelSetup.exe"
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter",,48)
For Each objNIC in colItems
pos3945 = InStr(objNIC.Name,"3945ABG")
pos2200 = InStr(objNIC.Name,"2200BG")
if pos3945 <> "0" or pos2200 <> "0" then
' \\ If an adapter exists, echo that it exists.
'wscript.echo "Intel NIC Exists"
IntelExists = "True"
end if
Next

If IntelExists = "True" then
If filesys.FileExists(ProgFiles.ExpandEnvironmentStrings("%PROGRAMFILES%") & "\Intel\Wireless\Drivers\iProDifx.dll") then
MyArray = Split(filesys.GetFileVersion(ProgFiles.ExpandEnvironmentStrings("%PROGRAMFILES%") & "\Intel\Wireless\Drivers\iProDifx.dll"),".")
' wScript.echo MyArray(0)
' wScript.echo MyArray(1)
' wScript.echo MyArray(2)
' wScript.echo MyArray(3)
MajVersion = CInt(MyArray(0))
' Wscript.echo MajVersion
MinVersion = CInt(MyArray(1))
BuildNum = CInt(MyArray(2))

If MajVersion < MajVer or MinVersion < MinVer or BuildNum < Build then
Set WshShell = CreateObject("WScript.Shell")
WshShell.Popup "Your system has an older version of the Intel Proset Software (for the Intel Wireless NIC Card) on your system." _
& vbCRLF & vbCRLF & "Press OK to update the driver. Please be patient as the install file is quite large (50 MB)!" & vbCRLF & vbCRLF _
& " ---- IT Department" & vbCRLF & vbCRLF _
& "Currently Installed Version: " & MajVersion & "." & MinVersion & "." & BuildNum & vbCRLF & vbCRLF _
& "Version to be Installed: " & MajVer & "." & MinVer & "." & Build,15,"Dell Quickset is out of Date!",48
'Wscript.echo BaseInstPath
' \\ Copy the install file to the %temp% directory for install. It will not work over the network.
filesys.CopyFile baseInstall, ProgFiles.ExpandEnvironmentStrings("%TEMP%" & "\IntelSetup.exe"),True
WshShell.Run (ProgFiles.ExpandEnvironmentStrings("%TEMP%") & "\IntelSetup.exe"),1,True
End If
else
' \\ Install Intel Software
filesys.CopyFile baseInstall, ProgFiles.ExpandEnvironmentStrings("%TEMP%" & "\IntelSetup.exe"),True
WshShell.Run (ProgFiles.ExpandEnvironmentStrings("%TEMP%") & "\IntelSetup.exe"),1,True
End If
End If

If err.number <> 0 then
call sendMail("Script error in Intel Wireless installation routine of os.vbs",vbCRLF & vbCRLF & "This user had an error while in the Intel wireless" & vbCRLF & vbCRLF & "Current Error = " & Err.Number)
End if
on error goto 0
End Sub

Sub sendMail (mailSubject,mailBody)

Set objEmail = CreateObject("CDO.Message")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject ("WScript.Shell")

computerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
userName = objShell.ExpandEnvironmentStrings("%USERNAME%")

if computerName = "WORKSTATIONXP" or computerName = "WORKSTATION2XP" then
exit sub
end if

objEmail.From = userName & "@somedomain.com"
objEmail.To = "Support@somedomain.com"
objEmail.Subject = mailSubject
objEmail.Textbody = "User: " & userName & " on computer \\" & computerName & " " & mailBody
objEmail.Configuration.Fields.Item _
(" = 2
objEmail.Configuration.Fields.Item _
(" = _
"smtp.somedomain.com"
objEmail.Configuration.Fields.Item _
(" = 25
objEmail.Configuration.Fields.Update
objEmail.Send

End Sub


It is what it is!!
__________________________________
A+, Net+, I-Net+, Certified Web Master, MCP, MCSA, MCSE, CCNA, CCDA, and few others (I got bored one day)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top