0

I have my file type .unitypackage e.g. something.unitypackage.

And I want to run the command "E:\Unity\2018.2.1f1\Editor\Unity.exe" -openfile "%1" whenever the something.unitypackage is executed (by Enter or double-click).

How do I achieve this?

It seems like "Opens with" doesn't allow specifying options for my command, so if I just choose Unity.exe to open with, it won't do -openfile "%1" option.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
off99555
  • 3,797
  • 3
  • 37
  • 49
  • The answer could be found [here](https://superuser.com/questions/361816/pass-command-line-arguments-to-windows-open-with). – Wander3r Aug 14 '18 at 09:18

1 Answers1

1

You can write a batch script unity.bat as following :

set params=%1
if "%params%" NEQ "" (E:\Unity\2018.2.1f1\Editor\Unity.exe -openfile %params%) else (E:\Unity\2018.2.1f1\Editor\Unity.exe)

Than you can 'open with' the .bat file.

  • It didn't work. The file is executed and nothing happens. Assume the file name is`"D:\off99555\Documents\Unity Projects\[All Assets]\[Scripting]\Best HTTP.unitypackage"` Does this takes into account the space and brackets characters? – off99555 Aug 16 '18 at 07:57
  • https://stackoverflow.com/questions/473117/pass-path-with-spaces-as-parameter-to-bat-file Try to change "%params%" to %params% – L. Chaumartin Aug 20 '18 at 07:22