Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

vbscript reg value

$
0
0

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.LogEvent4, "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
    
    IfNotIsNull(arrSubKeys) Then
        ForEach subkeyIn arrSubKeys
           ' WScript.Echo subkey
            strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & subkey
            strValueName = "DisplayName"
            oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
            
            IfInStr(LCase(strValue), LCase(strName)) > 0Then
            
                strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & subkey
                strValueName = "UninstallString"
                oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
                ObjShell.LogEvent4, "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"
                    
                                        
                EndIf
            EndIf
        Next
    EndIf

EndFunction




Support@Mytechnet.me


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>