I was only trying to show the logic not the complete script. Here is the complete script. I have a CA that runs the driver install during instal so I know the script engine is working. The install scrip is after theuninstall.
Thanks
Uinstall drivers VBS
On Error Resume Next
const AppName = "USB X(Driver Removal)"
const HKEY_LOCAL_MACHINE = &H80000002
Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
InstalledAppName = ""
InstalledAppName = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\DisplayName")
'Wscript.Echo InstalledAppName'
If InStr(InstalledAppName, AppName) > 0 then
RawGUID = ""
RawGUID = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\UninstallString")
If RawGUID<>"" then
WshShell.Run RawGUID
Exit For
End If
End If
Next
Install drivers VBS
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """" & Property("CustomActionData") & """",7,False
Set WshShell = Nothing