Add Function to register file Extensions

I’m new here, but not to the Toolkit, been using this for years now… :wink: I’m missing the ability to manually register file extensions for some applications. Maybe this can be added to the next release? This function here added the to the AppDeployToolkitMain.ps1 seems to do the trick however…

=============================================
Code

#region Function AssociateFileExtensions

<#Sypnosis

This assigns file types to installed applications on powershell.

Usage example, type AssociateFileExtensions -FileExtensions .txt,.sql -OpenAppPath “C:\Windows\System32\notepad.exe”
#>
Function AssociateFileExtensions
{
Param
(
[Parameter(Mandatory=$true)]
[String[]] $FileExtensions,
[Parameter(Mandatory=$true)]
[String] $OpenAppPath
)
if (-not (Test-Path $OpenAppPath))
{
throw “$OpenAppPath does not exist.”
}
foreach ($extension in $FileExtensions)
{
$fileType = (cmd /c “assoc $extension”)
$fileType = $fileType.Split("=")[-1]
cmd /c “ftype $fileType=”"$OpenAppPath"" “”%1"""
}
}

1 Like

Doesn’t this only work if it is run as a user in Windows 10?
Isn’t there a .Net / Powershell way of doing the same without CMD?