-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
LAPTOP\Stefán Ö Sigmundsson
committed
Nov 25, 2019
0 parents
commit 384dacc
Showing
3 changed files
with
769 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
eMI.FileNameExtensionProgramAssociation/AssociateFilesWithProgram.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<# | ||
Copyright © 2017, 2019 eMedia Intellect. | ||
This file is part of eMI FileNameExtension-ProgramAssociation Module. | ||
eMI FileNameExtension-ProgramAssociation Module is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
eMI FileNameExtension-ProgramAssociation Module is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with eMI FileNameExtension-ProgramAssociation Module. If not, see http://www.gnu.org/licenses/. | ||
#> | ||
|
||
Set-StrictMode -Version 'Latest' | ||
|
||
function AssociateFilesWithProgram | ||
{ | ||
Param | ||
( | ||
[Parameter(HelpMessage = 'The file name extensions to associate with the program.', Mandatory = $true)][String[]]$FileNameExtensions, | ||
[Parameter(HelpMessage = 'The file type name of the file name extensions.', Mandatory = $true)][String][ValidateScript({$_ -NotMatch '\s+'})]$FileTypeName, | ||
[Parameter(HelpMessage = 'The path to the program to which the file type name is associated.', Mandatory = $true)][String][ValidateScript({Test-Path $_})]$ProgramPath | ||
) | ||
|
||
Push-Location | ||
|
||
New-PSDrive -Name 'HKCR' -PSProvider 'Registry' -Root 'HKEY_CLASSES_ROOT' | ||
|
||
Set-Location HKCR: | ||
|
||
foreach ($fileNameExtension in $FileNameExtensions) | ||
{ | ||
New-Item -Force -Name $fileNameExtension -Value $FileTypeName | ||
} | ||
|
||
New-Item -Force -ItemType 'ExpandString' -Name 'Command' -Path ".\$FileTypeName\Shell\Open" -Value "`"$ProgramPath`" `"%1`"" | ||
|
||
Pop-Location | ||
} |
50 changes: 50 additions & 0 deletions
50
eMI.FileNameExtensionProgramAssociation/eMI.FileNameExtensionProgramAssociation.psd1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<# | ||
Copyright © 2017, 2019 eMedia Intellect. | ||
This file is part of eMI FileNameExtension-ProgramAssociation Module. | ||
eMI FileNameExtension-ProgramAssociation Module is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
eMI FileNameExtension-ProgramAssociation Module is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with eMI FileNameExtension-ProgramAssociation Module. If not, see http://www.gnu.org/licenses/. | ||
#> | ||
|
||
@{ | ||
Author = 'Stefán Örvar Sigmundsson' | ||
CompanyName = 'eMedia Intellect' | ||
Copyright = '(c) 2017, 2019 eMedia Intellect.' | ||
Description = 'A PowerShell module to associate file name extensions with programs.' | ||
GUID = '3043804b-68cd-40b5-86ec-ef93126ad7e2' | ||
HelpInfoURI = 'https://emi.is/?page=solutions&solution=emi-filenameextension-programassociation-module' | ||
ModuleVersion = '1.0.0.7' | ||
PrivateData = | ||
@{ | ||
PSData = | ||
@{ | ||
IconUri = 'https://emi.is/_images/logos/logo.ico' | ||
LicenseUri = 'https://www.gnu.org/licenses/gpl-3.0.en.html' | ||
ProjectUri = 'https://emi.is/?page=solutions&solution=emi-filenameextension-programassociation-module' | ||
Tags = | ||
@( | ||
'file-association', | ||
'file-extension', | ||
'file-extension-association', | ||
'file-name', | ||
'file-name-extension', | ||
'file-name-extension-association', | ||
'file-type', | ||
'file-type-association', | ||
'program-association' | ||
) | ||
} | ||
} | ||
RootModule = 'AssociateFilesWithProgram.psm1' | ||
} |
Oops, something went wrong.