Get Windows to treat files with the same extension differently

Windows does not launch files based on any information in the file - building a database for that would take an incredible amount of work and programming. The only true way to identify a file is by the binary signatures in the file, if the file even has it, and this is up to the software author to implement.

In Windows, files are passed to the program you specify for a particular file extension. Windows determines a file's extension as the substring which follows the last occurrence of a period, so it's not possible with the file names you posted.

You have to either re-name the files (and give them unique file extensions), or write a batch file to launch the appropriate application for you. For more details, see this Technet article.


I solved it myself:

I made a Python script that reads the first few bytes of a file and compares them to a dictionary, then launches the appropriate program based on the magic numbers.

import sys
import subprocess

magic_numbers = {
'OB': r'C:\Program Files (x86)\DesignSoft\Tina 9 - TI\TINA.EXE', # TINA
'*v': r'C:\Program Files (x86)\Orcad\Capture\Capture.exe', #PSpice
'DP': r'C:\Program Files (x86)\Design Explorer 99 SE\Client99SE.exe', #Protel
'\x00\xFE': r'C:\MentorGraphics\9.0PADS\SDD_HOME\Programs\powerlogic.exe', #PADS Logic
'\x10\x80': r'C:\Program Files (x86)\EAGLE-5.11.0\bin\eagle.exe', # Eagle
}

filename = sys.argv[1]
f = open(filename, 'rb')
# Read just enough bytes to match the keys
magic_n = f.read(max(map(len, magic_numbers)))

subprocess.call([magic_numbers[magic_n], filename])

Latest version will be here: Launch ambiguous files in the appropriate program

I tried to associate the file extension with this script, but Windows 7 didn't let me. It just associated it with Python instead, so I went into the registry and added the script name manually.

How to associate a file extension with a Python script

Room for improvement, but it works. I can double-click on different files with the same .sch extension and they open in different apps.

Update: I've converted it to an .exe using cx_freeze, with an external YAML config file, and it's easy to associate. See also this libmagic proposal. Not sure if I should make this into a full-fledged "libmagic launcher for Windows" or if it's better to handle only one file extension with one .exe and a simple YAML file.


To start, you can rename one of the types of files to have a new extension, and use the "open with" dialogue to set a default program to open those types of files.

This doesn't deal with the renaming problem though. But you simplify things by making a specific folder where you put all of the files from one of the programs. Then you can write a script to automatically rename files in that folder to your new file extension.

You may have trouble with an "Open File" dialogue in your program, depending on how it is set up. But if you have a single folder where all of your files are you should be able to just use that.

A more complicated, but potentially better way would be to create a proxy program. Keep all file extensions, but have them be opened by the proxy program. Have your program examine the binary and choose which type of file it is and which program to start. This will require you to spend some time writing your program, which may or may not be worth it to you.