VBSCRIPT: Install Drivers or Software Only For Specified Model in a Post Installation Task
Introduction:
The following script will run a DOS based command specified by the user if the model of the computer matches the one also specified by the user. This is to be used as a Post-Installation Task in a KACE K2000 environment to install drivers or software only on the model specified so that many of these tasks can be created and inserted into a single Scripted Installation that will properly address the driver installation needs of all models used by the organization without having to create multiple Scripted Installations.
Overview:
Some drivers require that an installation be ran for certain features to be active. The Driver Feed installation method from KACE does an excellent job of installing drivers from .inf files, but it does not handle the execution of installation executable files. The executable files may require a specific switch or argument which makes scripting for the numerous possibilities nigh impossible.
You can create a Post-Installation Task to handle the execution of these installation files, but it is ill-advised to install every driver on every system as some drivers may cause conflicts. Since you may have many computers of different models in your organization and since you do not desire these drivers to conflict, you would have to create a different Scripted Installation for each model type. If you have several Scripted Installations set up by departments and each department may be using many different models you would have to create an exponential amount of Scripted Installations.
Instead, you can use this script to check that the model matches what you desire and then run the command that is necessary to install the driver/software. Therefore, you can create different packages for different models and different drivers that all reside in the same Scripted Installation.
Example Scenario:
On a Dell OptiPlex 380 running Windows XP, the Realtek Audio driver requires that you run the Setup.exe file to properly install the audio drivers. If not used, the Volume Icon in the System Tray will not appear. For this example, we also have Dell OptiPlex 745’s and 780’s using the same Scripted Installation. So that we may continue to use only one Scripted Installation we would package this script with the installation files and configure the script to look for the OptiPlex 380 model and then run the command “Setup.exe /S” for a silent install. Then Zip up the files including the script, create a Post-Installation task titled “Driver - 380 - Realtek ALC269 HD Audio Driver x86”, and for the “Command Line” enter: “cscript.exe install.vbs”
Usage:
strModel = The desired computer to install on.
strCommand = The command to execute if the correct model is found.
K2000 Post-Installation Task Command Line:
cscript.exe install.vbs
The Script – install.vbs
'Script to install Driver on a specific Model of Computer.
'User specified data
strModel = "OptiPlex 380" 'Required Model number for this install
strCommand = "Setup.exe /S" 'Command to execute if desired Model is found
'Global Variables and Settings
Set objShell = WScript.CreateObject ("WSCript.shell")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colManufacturer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
strLength = Len(strModel)
'Determine Manufacturer Model Number
For each objManufacturer in colManufacturer
strManModel = objManufacturer.Model
Next
'Check Manufacture Model against provided Model and if matched, run Command.
If Left(Ucase(strManModel),strLength) = UCase(strModel) Then
objShell.run strCommand, 0, True
End If
'Veritas Amor Pax
Veritas Amor Pax
Comments