Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ The file extension to be associated.
.PARAMETER Executable
The path to the application's executable to be associated.

.PARAMETER Arguments
Specifies how the file name and CLI arguments are passed to the executable.
Default value is `"%1" "%*"`; another example: `-o "%1"`, if executable
requires it. Use `%1`, `%2`, `%3`, etc. to refer to first, second, third,
etc. arguments. `%*` refers to all arguments, `$~n` refers to all arguments
starting with argument n (2 <= n <= 9).

.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply. Do not use directly.

Expand All @@ -57,6 +64,7 @@ Install-ChocolateyFileAssociation ".txt" $sublimeExe
param(
[parameter(Mandatory = $true, Position = 0)][string] $extension,
[parameter(Mandatory = $true, Position = 1)][string] $executable,
[parameter(Mandatory=$false, Position=2)][string] $arguments = '"%1" "%*"',
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)

Expand All @@ -75,7 +83,7 @@ Install-ChocolateyFileAssociation ".txt" $sublimeExe
$fileType = $fileType.Replace(" ", "_")
$elevated = @"
cmd /c "assoc $extension=$fileType"
cmd /c 'ftype $fileType="$executable" "%1" "%*"'
cmd /c 'ftype $fileType="$executable" $arguments'
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
Set-ItemProperty -Path "HKCR:\$fileType" -Name "(Default)" -Value "$fileType file" -ErrorAction Stop
"@
Expand Down
Loading