Dear Exprt,
by below script i can get stringname but not getting uninstall software what wrong in could you plz advice
GetProductCode("Mytestapplication")
'//----------------------------------------------------------------------------
'// Procedures
'//----------------------------------------------------------------------------
Function GetProductCode(strName)
Dim strComputer, oReg, strKeyPath, strValueNAme, strValue, arrSubKeys, subkey
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
arrSubKeys = Null
Set ObjShell = CreateObject("WScript.Shell")
ObjShell.LogEvent 4, "Seaching in registry for installed products by search term: " & strName
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
If Not IsNull(arrSubKeys) Then
For Each subkey In arrSubKeys
' WScript.Echo subkey
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & subkey
strValueName = "DisplayName"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If InStr(LCase(strValue), LCase(strName)) > 0 Then
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & subkey
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
ObjShell.LogEvent 4, "Found Installed "& strName &" product Code: " & Replace(Replace(strValue, "MsiExec.exe /X",""), "MsiExec.exe /I","")
If strValue <> "" Then
GetProductCode = Replace(Replace(strValue, "MsiExec.exe /X",""), "MsiExec.exe /I","")
ObjShell.Exec "MsiExec.exe /X GetProductCode /Q"
End If
End If
Next
End If
End Function
Support@Mytechnet.me