@@ -42,6 +42,13 @@ The file extension to be associated.
42
42
. PARAMETER Executable
43
43
The path to the application's executable to be associated.
44
44
45
+ . PARAMETER Arguments
46
+ Specifies how the file name and CLI arguments are passed to the executable.
47
+ Default value is `"%1" "%*"`; another example: `-o "%1"`, if executable
48
+ requires it. Use `%1`, `%2`, `%3`, etc. to refer to first, second, third,
49
+ etc. arguments. `%*` refers to all arguments, `$~n` refers to all arguments
50
+ starting with argument n (2 <= n <= 9).
51
+
45
52
. PARAMETER IgnoredArguments
46
53
Allows splatting with arguments that do not apply. Do not use directly.
47
54
@@ -57,6 +64,7 @@ Install-ChocolateyFileAssociation ".txt" $sublimeExe
57
64
param (
58
65
[parameter (Mandatory = $true , Position = 0 )][string ] $extension ,
59
66
[parameter (Mandatory = $true , Position = 1 )][string ] $executable ,
67
+ [parameter (Mandatory = $false , Position = 2 )][string ] $arguments = ' "%1" "%*"' ,
60
68
[parameter (ValueFromRemainingArguments = $true )][Object []] $ignoredArguments
61
69
)
62
70
@@ -75,7 +83,7 @@ Install-ChocolateyFileAssociation ".txt" $sublimeExe
75
83
$fileType = $fileType.Replace (" " , " _" )
76
84
$elevated = @"
77
85
cmd /c "assoc $extension =$fileType "
78
- cmd /c 'ftype $fileType ="$executable " "%1" "%*" '
86
+ cmd /c 'ftype $fileType ="$executable " $arguments '
79
87
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
80
88
Set-ItemProperty -Path "HKCR:\$fileType " -Name "(Default)" -Value "$fileType file" -ErrorAction Stop
81
89
"@
0 commit comments