4

I am in an enterprise environment and I am trying to set the default apps on several systems by using a .bat script. This is what my script is doing, nothing complicated.

@ECHO OFF
dism /online /Import-DefaultAppAssociations:"%~dp0\MyDefaultAppAssociations_Modified.xml"

However, I have noticed that it works on some work stations and not working on others. Any ideas on what would be causing that? The only thing I could think of is that the Program IDs in the XML file may change from computer to computer but I can't imagine that is the case. Any ideas or other methods on how to accomplish setting default apps are welcome.

UPDATE: This script will either work complete and properly or it will not work at all. I have yet to see it where it only updates certain default apps.

8
  • Hello. Just asking, but is it possible that there wasn't an administrator account active for the workstations that didn't work? Also, please specify if it doesn't work at all or just partially (some apps become default after the script) on these workstations to help others.
    – Natsu Kage
    Jan 23, 2020 at 21:03
  • I am executing the script from my admin account and then logging in with a dummy account to ensure that the default apps are being set properly. I read that this is actually a bug and the account that uploads this XML file does not get the change applied but the other accounts do. (This has been a bug since 2015) Jan 23, 2020 at 21:07
  • So is there anything of value in C:\WINDOWS\Logs\DISM\dism.log?
    – DavidPostill
    Jan 23, 2020 at 21:08
  • @DavidPostill I don't seem to have that file location. Even when I unhide things.... I did use the Windows 10 Upgrade tool to upgrade from Windows 7 and I am wondering if that is causing my issue. Jan 23, 2020 at 21:13
  • Are these workstations all running the same Windows version? (1709, 1903, etc). The documentation on doing imports says that it may be an issue. Not sure on your side.
    – Natsu Kage
    Jan 23, 2020 at 21:17

1 Answer 1

4

For each of the filetypes that you want to set a default app for, find the filetype it is associated with.

For XML, at a CMD prompt execute this:

Assoc .xml

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/assoc

That will tell you the filetype is "xmlfile"

To set the default app for an "xmlfile", you'll use Ftype:

Ftype xmlfile=C:\Program Files (x86)\Notepad++\notepad++.exe %1

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/ftype

Once you know the filetype for each of your extensions, add a line for each of them to your batch file.

2
  • 1
    On Window 10, I've found assoc to be unreliable. For example, on one PC, "File association not found for extension .pdf", though clearly PDF files are associated with my default app, Sumatra, and show as such in Explorer and open correctly when double-clicked. Jan 23, 2020 at 22:09
  • Microsoft has introduced other means of associations over the years. While most apps use traditional associations they can use various DDE, COM, Context Menu extensions (how Word can open only HTML files it created). Also if Windows cannot find an extension it will look in the COM database for the COM filetype, then it will do content sniffing.
    – Mark
    Jan 23, 2020 at 23:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .