Windows 10 has the wonkiest Default Programs assigned and I need to be able to quickly change them on different machines (i.e. create a script). I am trying to use assoc and ftype to accomplish that.
This is the batch file I tried to run - simple enough to start with. PS1 files usually open in Notepad, which makes no sense as they should open in the PowerShell ISE, so that is what I tried to do here:
@echo off
TITLE Associating File Types With Applications for %username%
assoc .ps1=Microsoft.PowerShellScript.1
ftype Microsoft.PowerShellScript.1=powershell_ise.exe
pause
The pause was simply so I could capture the following error when it ran:
Access is denied.
Error occurred while processing: .ps1.
Access is denied.
Error occurred while processing: Microsoft.PowerShellScript.1.
Press any key to continue . . .
Double access denied! The way the script is currently written, neither assoc or ftype work. I can change Default Programs through the GUI, so I should be able to script it as well. Unfortunately, Microsoft doesn't make it easy to script when you are not an Administrator.
I don't know if the assoc part is actually necessary - it seems like only ftype is needed in a script as that is what actually changes the file association. That was in all the examples though so I included it.
How can I change default programs as a standard user without any administrative rights? Thankfully, we now have access to the Registry, so if I can do the same thing with a REG file, that would work as well. I need to be able to associate the following file types with the following programs:
- PS1: PowerShell ISE
- PDF: Adobe Acrobat Reader DC
- Make Windows Photo Viewer (not Photos) the default viewer for any type of image. I already have a script that adds WPV to the "Open With" menu.
- Make Windows Media Player the default viewer for any type of video file.
- Make Internet Explorer the default browser (as opposed to Edge). Our domain has a policy that makes Chrome the default browser whenever it runs, so I may reapply this more often.
- HTML/CSS/JS: "T:\Notepad++\Notepad++Portable.exe"
Apart from Chrome, domain policies do not affect default programs.