Forum Discussion

giriprasasd100's avatar
giriprasasd100
Occasional Contributor
15 years ago

Conflict in TestComplete and Windows Host script results

Hi All,



I am running a small WMI script in TestComplete 7.20.562.7 version on Windows Server 2008 machine with service pack 1.



The script will list all the installed programs along with total count.

While trying to run in TestComplete and as simple VBScript file in WindowsHost with necessary modifications(Log.Message in TestComplete and WScript.Write in Windows Script Host), the output is not same in both the cases...



The TestComplete version's output is getting conflict with Windows Script Host version output. Also my indented installed software is missing in TestComplete output.



Also while running the same scripts in Windows XP and Windows Server 2003 machines, both the results are perfectly matching !!!



Please find the script used...

VBScript

==================================

Set objNetwork = Wscript.CreateObject("Wscript.Network")

Set objStdOut = WScript.StdOut



    Dim count : count = 0

    strHost = "."

    Const HKLM = &H80000002

    Set objReg = GetObject("winmgmts://" & strHost & "/root/default:StdRegProv")

    Const strBaseKey = "Software\Microsoft\Windows\CurrentVersion\Uninstall\"

    objReg.EnumKey HKLM, strBaseKey, arrSubKeys

 

    For Each strSubKey In arrSubKeys

        intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, _

            "DisplayName", strValue)

        If intRet <> 0 Then

            intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, _

            "QuietDisplayName", strValue)

        End If

        If (strValue <> "") and (intRet = 0) Then

            count = count + 1

        End If

Next

     objStdOut.Write "Count: " & count

objStdOut.Close

----------------------------------------------------------------

TestComplete script

===========================================

Sub list

    Dim count : count = 0

    strHost = "."

    Const HKLM = &H80000002

    Set objReg = GetObject("winmgmts://" & strHost & "/root/default:StdRegProv")

    Const strBaseKey = "Software\Microsoft\Windows\CurrentVersion\Uninstall\"

    objReg.EnumKey HKLM, strBaseKey, arrSubKeys

 

    For Each strSubKey In arrSubKeys

        intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, _

            "DisplayName", strValue)

        If intRet <> 0 Then

            intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, _

            "QuietDisplayName", strValue)

        End If

        If (strValue <> "") and (intRet = 0) Then

            Log.Message(strValue)

            count = count + 1

        End If

Next

     Log.Message("Total Count:" & count)



End Sub

-----------------------------------------------------------------------

Is this a known issue or it depends up on OS ?



Please help in solving this issue.



Thanks in advance



Regards,

Giri Prasad





4 Replies

  • Hi Giri,




    Do you use an x64 OS? 




    If you do, most likely, the issue is caused by the fact that you read different registry branches by TC and an external script.




    The branch you need to read has two locations in x64 systems:

    (the 64-bit registry) :HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\

    (the 32-bit registry) :HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\




    An external script is executed by Windows Script Host 64-bit and, by default, accesses the 64-bit registry version, while TC is a 32-bit application, it accesses the 32-bit registry version.




    To work with the same registry version, you need to use the Storages object in TC (see the "Storages.Registry" help topic) that can work with both registry versions.

  • Hi Giri,



    The Storages object is not available inside a script extension. We have an appropriate suggestion in our DB, and your message has increased its rating.



    If you need to work with the registry from a script extension, it would be better if you used your initial script, but with the __ProviderArchitecture flag.



    See the following MSDN Library article for more information:

    http://msdn.microsoft.com/en-us/library/aa393067(VS.85).aspx



    Here is an example:

    http://david.gardiner.net.au/2007/03/listing-installed-applications-on-vista.html

  • giriprasasd100's avatar
    giriprasasd100
    Occasional Contributor
    Thanks David for your support !!!



    Yes, I am using a 64-Bit OS. By switching to 64-Bit registry, I am able to get desired information.



    While implementing the same function through Script Extension, the "Storages" and "TestedApps" Object is not recongnized as TestComplete objects. An exception "Storages - is undefined"occurs when I try to run the extension.



    Please help me in solving this block.



    Thankful as always

    Giri Prasad