1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Get-wmiobject Question

Discussion in 'Windows 7' started by gw1500se, 2016/05/14.

  1. 2016/05/14
    gw1500se

    gw1500se Well-Known Member Thread Starter

    Joined:
    2003/01/10
    Messages:
    444
    Likes Received:
    0
    I am trying to write a PowerShell script that checks for certain installation information. I was able to write a query that successfully returns the information about an application but it did not include the 'PATHNAME'. Is there something I am missing in the query to make sure that is included in the returned data? TIA.

    Get-WmiObject -Class Win32_Product | ?{$_.Name -like "Python*2.7* "}
     
  2. 2016/05/14
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
    The Win32_Product class has a Property that can be returned:
    InstallLocation
    ...but ONLY if the product was installed using Windows MSI installer.

    It's possible its installer has the InstallLocation set to NULL, in which case the value returned will be empty. You may be better off querying the registry Software keys.
     
    Last edited: 2016/05/14

  3. to hide this advert.

  4. 2016/05/14
    gw1500se

    gw1500se Well-Known Member Thread Starter

    Joined:
    2003/01/10
    Messages:
    444
    Likes Received:
    0
    Thanks for the reply. I guess I need to rethink my methodology.
     
  5. 2016/05/15
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
     
  6. 2016/05/15
    gw1500se

    gw1500se Well-Known Member Thread Starter

    Joined:
    2003/01/10
    Messages:
    444
    Likes Received:
    0
    Thanks. It took me a while to figure out what you meant so I'm probably doing it wrong but what I did doesn't work:

    Get-ItemProperty "hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths "

    Returns nothing.
     
  7. 2016/05/15
    lj50 Lifetime Subscription

    lj50 SuperGeek WindowsBBS Team Member

    Joined:
    2003/07/04
    Messages:
    2,801
    Likes Received:
    137
    If you created the key GetItemProperty Try removing the hyphen
     
    lj50,
    #6
  8. 2016/05/15
    gw1500se

    gw1500se Well-Known Member Thread Starter

    Joined:
    2003/01/10
    Messages:
    444
    Likes Received:
    0
    I guess I'm lost. I did not create any key. Get-ItemProperty is a powershell cmdlet that I thought I was supposed to use to get the registry data.
     
  9. 2016/05/16
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
  10. 2016/05/16
    gw1500se

    gw1500se Well-Known Member Thread Starter

    Joined:
    2003/01/10
    Messages:
    444
    Likes Received:
    0
    Thanks but that is not much help. I added -Path to my cmdlet but still get nothing back:

    Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths "
     
  11. 2016/05/17
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
    Well, the installed software MUST be registered in order for it to have a Reg Key value. Verify the value exists in the registry. Not all software registers in the registry when it's installed, esp custom software & older software. Ot its path may be put into a different registry location. Find the registry keys the software creates when it's installed.

    And verify your cmdlet is coded standardly per that MS Guidelines.
    If the software does not use the Windows Installer or does not create registry values during install you must use the techniques outlined here: Working with Files and Folders
     
    Last edited: 2016/05/17
  12. 2016/05/17
    gw1500se

    gw1500se Well-Known Member Thread Starter

    Joined:
    2003/01/10
    Messages:
    444
    Likes Received:
    0
    But doesn't that cmdlet return all installed apps? I'm not asking for a specific one in that query yet.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.