2

I need to open files of type .unitypackage using the command Unity.exe -openfile "%1", but if I "right-click -> open with" it only allows me to select the program, not the command line options.

What can I do to fix that on Windows 8.1?

2 Answers 2

5
+50

There are a few different options to set a file association in Windows 8. Unfortunately, the built-in methods tend not to support any fancy like custom command-line arguments.

  • You can right-click a file and select Open With, then Choose Default Program to browse for the program. You will likely need to manually edit the registry to add the -openfile switch.

  • You can set file associations with the Set Default Programs app; again you will need to manually modify the registry to include the switch.

    If you go this route, then you can do it as follows:

    1. Select Settings
    2. Type associate
    3. Select Change the file type associated with a file extension
    4. Select the file extension
    5. Click the [Change Program] button

    Note, you may not see the file extension in the list if you have not previously tried to open the file (for example with the previous method).

  • Use a third-party program like FileTypesMan to create a file association. With FileTypesMan, you could do it as so:

    1. Edit → New File Extension (or Ctrl+T)
    2. Fill out the dialog to create an extension .unitypackage: Screenshot of New File Extension dialog
    3. Actions → New Action (or Ctrl+N)
    4. Fill out the dialog: Screenshot of New Action dialog
  • Manually create the registry entries for the association. I’ve taken the liberty of whipping one up for you. Just copy it to a plain-text file, make sure to save it with an extension of .reg, not .reg.txt (you can do this by selecting All Files (*.*) in the file-type drop-down in the Save As dialog). Then run the saved registry script and accept to merge it. You can use hard-coded paths (which you can edit if needed in the text-editor) or use variables by uncommenting the specified lines (you would need to edit those in Regedit since they are encoded as hexadecimal).

    REGEDIT4
    
    [HKEY_CLASSES_ROOT\.unitypackage]
    @="UnityPackage"
    
    [HKEY_CLASSES_ROOT\UnityPackage]
    @="Unity Package"
    
    [HKEY_CLASSES_ROOT\UnityPackage\Shell\DefaultIcon]
    @="\"C:\\Program Files (x86)\\Unity\\Editor\\Unity.exe\",1"
    ; Uncomment the line below by removing the leading semi-colon to use an environment variable ("%ProgramFiles(x86)%\Unity\Editor\Unity.exe",1) instead of the hard-coded path above.
    ;@=hex(2):22,25,50,72,6f,67,72,61,6d,46,69,6c,65,73,28,78,38,36,29,25,5c,55,6e,69,74,79,5c,45,64,69,74,6f,72,5c,55,6e,69,74,79,2e,65,78,65,22,2c,31,00
    
    [HKEY_CLASSES_ROOT\UnityPackage\Shell\Open]
    @="&Open"
    
    [HKEY_CLASSES_ROOT\UnityPackage\Shell\Open\Command]
    @="\"C:\\Program Files (x86)\\Unity\\Editor\\Unity.exe\" -openfile \"%1\""
    ; Uncomment the line below by removing the leading semi-colon to use an environment variable ("%ProgramFiles(x86)%\Unity\Editor\Unity.exe") instead of the hard-coded path above.
    ;@=hex(2):22,25,50,72,6f,67,72,61,6d,46,69,6c,65,73,28,78,38,36,29,25,5c,55,6e,69,74,79,5c,45,64,69,74,6f,72,5c,55,6e,69,74,79,2e,65,78,65,22,20,2d,6f,70,65,6e,66,69,6c,65,20,22,25,31,22,00
    

(Note: I do not have Unity installed on my current machine, so I cannot check the icons included in the binary, so you may need to change the ,1 in the DefaultIcon settings in the registry script and dialogs to something more appropriate like ,3 or ,10 or something, if it doesn’t include any document icons at all, then either use ,0 or remove that part altogether.)

2

On Windows 7, they registy key HKEY_CLASSES_ROOT\txtfile\shell\print\command contains "%SystemRoot%\system32\NOTEPAD.EXE /p %1". If you find the key for your file type, perhaps changing it to Unity.exe -openfile %1 will work even on Windows 8.1

3
  • That’s not much of an answer; this is more of a um-well-try-this comment. A proper answer would include specific instructions. Consider editing to improve this post.
    – Synetech
    Nov 19, 2013 at 15:23
  • @Synetech the doing it by hand is not an issue, though it's more of an issue the "well randomly try this, maybe it works". I'll certainly try it if no one else comes up with anything more certain.
    – o0'.
    Nov 19, 2013 at 15:40
  • 1
    @Lohoris, sounds reasonable (though someone thought that the *try this and see if it applies*—and without any formatting either) was good enough to up-vote it. :-P Anyway, I threw something a little more useful together, hopefully that will do the trick.
    – Synetech
    Nov 19, 2013 at 16:02

You must log in to answer this question.

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