Skip to content

Commit

Permalink
Committing.
Browse files Browse the repository at this point in the history
  • Loading branch information
LAPTOP\Stefán Ö Sigmundsson committed Nov 25, 2019
0 parents commit 384dacc
Show file tree
Hide file tree
Showing 3 changed files with 769 additions and 0 deletions.
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
}
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'
}
Loading

0 comments on commit 384dacc

Please sign in to comment.