Skip to content

Commit 384dacc

Browse files
author
LAPTOP\Stefán Ö Sigmundsson
committed
Committing.
0 parents  commit 384dacc

File tree

3 files changed

+769
-0
lines changed

3 files changed

+769
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<#
2+
Copyright © 2017, 2019 eMedia Intellect.
3+
4+
This file is part of eMI FileNameExtension-ProgramAssociation Module.
5+
6+
eMI FileNameExtension-ProgramAssociation Module is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
eMI FileNameExtension-ProgramAssociation Module is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with eMI FileNameExtension-ProgramAssociation Module. If not, see http://www.gnu.org/licenses/.
18+
#>
19+
20+
Set-StrictMode -Version 'Latest'
21+
22+
function AssociateFilesWithProgram
23+
{
24+
Param
25+
(
26+
[Parameter(HelpMessage = 'The file name extensions to associate with the program.', Mandatory = $true)][String[]]$FileNameExtensions,
27+
[Parameter(HelpMessage = 'The file type name of the file name extensions.', Mandatory = $true)][String][ValidateScript({$_ -NotMatch '\s+'})]$FileTypeName,
28+
[Parameter(HelpMessage = 'The path to the program to which the file type name is associated.', Mandatory = $true)][String][ValidateScript({Test-Path $_})]$ProgramPath
29+
)
30+
31+
Push-Location
32+
33+
New-PSDrive -Name 'HKCR' -PSProvider 'Registry' -Root 'HKEY_CLASSES_ROOT'
34+
35+
Set-Location HKCR:
36+
37+
foreach ($fileNameExtension in $FileNameExtensions)
38+
{
39+
New-Item -Force -Name $fileNameExtension -Value $FileTypeName
40+
}
41+
42+
New-Item -Force -ItemType 'ExpandString' -Name 'Command' -Path ".\$FileTypeName\Shell\Open" -Value "`"$ProgramPath`" `"%1`""
43+
44+
Pop-Location
45+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<#
2+
Copyright © 2017, 2019 eMedia Intellect.
3+
4+
This file is part of eMI FileNameExtension-ProgramAssociation Module.
5+
6+
eMI FileNameExtension-ProgramAssociation Module is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
eMI FileNameExtension-ProgramAssociation Module is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with eMI FileNameExtension-ProgramAssociation Module. If not, see http://www.gnu.org/licenses/.
18+
#>
19+
20+
@{
21+
Author = 'Stefán Örvar Sigmundsson'
22+
CompanyName = 'eMedia Intellect'
23+
Copyright = '(c) 2017, 2019 eMedia Intellect.'
24+
Description = 'A PowerShell module to associate file name extensions with programs.'
25+
GUID = '3043804b-68cd-40b5-86ec-ef93126ad7e2'
26+
HelpInfoURI = 'https://emi.is/?page=solutions&solution=emi-filenameextension-programassociation-module'
27+
ModuleVersion = '1.0.0.7'
28+
PrivateData =
29+
@{
30+
PSData =
31+
@{
32+
IconUri = 'https://emi.is/_images/logos/logo.ico'
33+
LicenseUri = 'https://www.gnu.org/licenses/gpl-3.0.en.html'
34+
ProjectUri = 'https://emi.is/?page=solutions&solution=emi-filenameextension-programassociation-module'
35+
Tags =
36+
@(
37+
'file-association',
38+
'file-extension',
39+
'file-extension-association',
40+
'file-name',
41+
'file-name-extension',
42+
'file-name-extension-association',
43+
'file-type',
44+
'file-type-association',
45+
'program-association'
46+
)
47+
}
48+
}
49+
RootModule = 'AssociateFilesWithProgram.psm1'
50+
}

0 commit comments

Comments
 (0)