Qinto
Qinto

Reputation: 205

How do I get the default mail client using Powershell?

I want to get the default mail client from Powershell script.

I know that this information is stored in the windows registry: HKEY_CLASSES_ROOT\mailto\shell\open\command but the HKCR is not available by default from Powershell.

Do you know any way to access the above key or to get the default mail client in another way?

Thanks in advance, Qinto.

Upvotes: 0

Views: 5070

Answers (1)

Joey
Joey

Reputation: 354566

HKEY_CLASSES_ROOT is an amalgamation of HKEY_LOCAL_MACHINE\Software\Classes and HKEY_CURRENT_USER\Software\Classes.

So you can do it as follows:

$node = Get-ItemProperty HKCU:\Software\Classes\mailto\shell\open\command
if (!$node) { $node = Get-ItemProperty HKCU:\Software\Classes\mailto\shell\open\command }
$MailClient = $node.'(default)'

Upvotes: 3

Related Questions