Trying to Find Test-Path for Outlook without Full Path

Hello,


I am attempting to check whether Outlook is installed on a PC, before attempting to force start it.

I would like to use the shortcut name "Outlook" instead of directly typing the whole path to outlook as that may vary per OS/version.

I tried:

$OutlookProcess="Outlook"

if (Test-Path $Outlook)

{

Start-Process $OutlookProcess

}


without success. 

Any pointers appreciated.

Many thanks in advance


February 20th, 2015 6:46pm

you could try looking for a registry entry or use a WMI query

Get-WmiObject -Class Win32_Product | Where { $_.Name -like "*Outlook*" }

Free Windows Admin Tool Kit Click here and download it now
February 20th, 2015 7:03pm

This is much faster:

function Test-Outlook{
    Try{
        $ol=New-Object -ComObject outlook.Application
        $true
    }
    catch{
        $false
    }
}

As is this:

Get-WmiObject Win32_Product -filter 'Name like "%Outlook%"'

February 20th, 2015 9:09pm

Hello,


I am attempting to check whether Outlook is installed on a PC, before attempting to force start it.

I would like to use the shortcut name "Outlook" instead of directly typing the whole path to outlook as that may vary per OS/version.

I tried:

$OutlookProcess="Outlook"

if (Test-Path $Outlook)

{

Start-Process $OutlookProcess

}


without success. 

Any pointers appreciated.

Many thanks in advance



The script is conditional on the existence of whatever kind of object is contained within the $Outlook variable, but the scripts does not assign that variable a value.
Free Windows Admin Tool Kit Click here and download it now
February 21st, 2015 1:32am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics