Tuesday, March 8, 2011

PowerShell | How to know if an Application is installed?

Let's find out if Microsoft Word is installed on the system:


if ((dir REGISTRY::HKEY_CLASSES_ROOT\Word.Application) -ne $Null)
{
#do word installed stuff such as
$myWord = New-Object -Com Word.Application
$myWord.Visible = $true
}

Another option would be to catch the exception launched from the failed new-object

Thanks to
http://www.virtu-al.net/2008/08/07/powershell-is-microsoft-word-installed/

No comments:

Post a Comment