Jump to content
  • 0

executable file association proposed simple solution


g96968

Question

There's a known problem when using executables with Mod Organizer and programs like NifSkope where you can't associate files to the internal executable.

My solution is pretty straight forward: pass the arguments forward.

 

That is, currently ModOrganizer.exe takes the first argument and executes it after applying* the internal virtual file system. My solution is to just forward the following arguments to the executable. Then, a user could associate a batch file to the desired extension as follows:

@echo off
C:\Games\ModOrganizer\ModOrganizer.exe "C:\Games\ModOrganizer\mods\NifSkope\NifSkope\NifSkope.exe" %1

This will cleanly pass the first argument. It's even possible to pass all arguments forward using:

@echo off
C:\Games\ModOrganizer\ModOrganizer.exe "C:\Games\ModOrganizer\mods\NifSkope\NifSkope\NifSkope.exe" %*

Anyhow, that's just my two cents.

 

Thanks

 

 

 

 

* no clue how that works... I'm not too familiar with how windows does these things. In linux it would likely get done with containers these days or links or mounts... I don't think either system has union mounts...

Edited by g96968
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

I'm not sure how your system is set up but any file associated with a programme is called by MO when that filetype is 'Opened'.

So in the example above, *.nif files are associated with NifSkope and when you examine a mod in MO that has *.nifs you can invoke the context menu, select "Open/Execute" (from the 'Data' tab) or "Open" (from the "Information" -- 'Fileview' dialogue) and NifSkope is called with that file passed. The only time that doesn't work is when the file is inside a *.bsa and you try to examine it via the 'Data' tab.

Link to comment
Share on other sites

  • 0

I'm not sure how your system is set up but any file associated with a programme is called by MO when that filetype is 'Opened'.

So in the example above, *.nif files are associated with NifSkope and when you examine a mod in MO that has *.nifs you can invoke the context menu, select "Open/Execute" (from the 'Data' tab) or "Open" (from the "Information" -- 'Fileview' dialogue) and NifSkope is called with that file passed. The only time that doesn't work is when the file is inside a *.bsa and you try to examine it via the 'Data' tab.

First off, let me switch to talking about CreationKit.exe instead of NifSkope since it's the wider case and it's an official part of the game so supporting it's proper functionality is palatable.

Now, I'm not talking about inspecting *.nif files from MO. I'm talking about the system-wide associations. So, in my case, say I'm working on a an armor piece and I'm constantly opening and reopening *.nif files from the file manager (My Computer/explorer.exe) since the nif plugins for 3dsmax and maya are buggy requiring frequent export/imports.

Normally the association is to CreationKit.exe but if I'll just double click the file in the file manager following this direct association then I'll get a CreationKit.exe instance that's working outside MO virtual file system and it won't have access to my mods and overwrites where I actually store my modified textures and such.

So, my suggestion is to modify MO to pipe (pass-on) the extra arguments it gets in stdin to it's stdout. Then write a small batch file like the one I showed above and associate *.nif files to that.

 

Btw, my current solution is to open CreationKit.exe (well, actually I use NifSkope for these things but for the sake of this example) from MO and then open the file I want from there. It's a clunky and slow workflow and makes my life hard since I also need to restart Skyrim frequently to test out mesh adjustments if I'm fitting a piece of armor to a body.

Link to comment
Share on other sites

  • 0

Either you're not explaining it clearly, or I'm not understanding it clearly, or both, but I still don't see where the issue/solution is.

 

Let me try again. What you are asking is for the ability from within Windows explorer, or any other file manger, to pass the argument to MO so that it's VFS is called and then the correct assets are available? Have I got it this time?

If so then perhaps an easy way would be to use the FreeCommander workaround found in the wiki and call that file manager from MO and then all your files that are available to the game in MO's VFS are also available in an environment like Windows explorer.

 

It does seem though like you are looking for an easy way around the need to call MO to use it's VFS. I can't see how we can avoid that easily.

Link to comment
Share on other sites

  • 0

Oh I already have a straight-forward workaround using a named pipe. I was just looking for a proper fix.

 

But here's my NifSkope workaround for future reference:

1. Place NifSkope in it's own mod dir. The resulting dir structure as follows in my case:

C:\Games\ModOrganizer\ModOrganizer.exe

C:\Games\ModOrganizer\mods\NifSkope\NifSkope\NifSkope.exe

2. Download createAndWritePipe.exe off https://github.com/psmay/windows-named-pipe-utils/releases

3. Place it so:

C:\Games\ModOrganizer\mods\NifSkope\NifSkope\createAndWritePipe.exe

4. Write C:\Games\ModOrganizer\mods\NifSkope\NifSkope\NifSkopeMO.bat as follows:

@echo off
start C:\Games\ModOrganizer\ModOrganizer.exe C:\Games\ModOrganizer\mods\NifSkope\NifSkope\NifSkope.bat
echo %* | "C:\Games\ModOrganizer\mods\NifSkope\NifSkope\createAndWritePipe.exe" NifSkope

5. Write C:\Games\ModOrganizer\mods\NifSkope\NifSkope\NifSkope.bat as follows:

@echo off
FOR /F "delims=" %%i IN ('type \\.\pipe\NifSkope') DO NifSkope.exe %%i

6. Open Mod Manager and add NifSkope.bat as an executable.

7. right click any nif file, Open with -> Choose default program... browse and select NifSkopeMO.bat.

 

The end result is that NifSkopeMO.bat will create a named pipe storing the arguments. Then MO will initiate NifSkope.bat which will read that named pipe and run NifSkope.exe with those arguments.

 

It's a simple enough solution but you can circumvent a lot of hoops (creating the named pipe and depending on another executable to do so) by having MO just pass arguments forward to the executable it's been asked to run.

 

Edit: If you have spaces in your path to NifSkope.bat you might need to escape them by using quotation marks or carat ("^").

Edited by g96968
Link to comment
Share on other sites

  • 0

I'm confused. MO does forward all arguments after the executablename to the exe.

If you run "ModOrganizer.exe C:\windows\system32\notepad.exe test.txt" it will start notepad with the vfs enabled and test.txt opened. How doesn't this fulfil your requirement?

Link to comment
Share on other sites

  • 0

I'm confused. MO does forward all arguments after the executablename to the exe.

If you run "ModOrganizer.exe C:\windows\system32\notepad.exe test.txt" it will start notepad with the vfs enabled and test.txt opened. How doesn't this fulfil your requirement?

Hmm... Yes you're right it seems to work... Sometimes. But, when I try:

C:\Games\ModOrganizer\ModOrganizer.exe C:\Games\ModOrganizer\mods\NifSkope\NifSkope\NifSkope.exe "C:\home\public\skyrim_armour_from_scratch\CA4S - Creating Armors for Skyrim - Nightasy\unp custom armor\data\meshes\armor\hide\f\fin2\cuirasslight_0.nif"

NifSkope fails to locate the file and reports that "C:\Games\Skyrim\data\NifSkope\armor\data\meshes\armor\hide\f\fin2\cuirasslight_0.nif" wasn't found... But this works fine if I direct it to Notepad.exe instead of NifSkope.exe... Maybe MO is trying to be clever and is modifying the path of the file if the executable is defined in the VFS even though it's out of bounds (from the VFS)? Or maybe it's striping the quotation mark? Or maybe NifSkope isn't handling the file path argument properly unlike notepad?

 

Doesn't matter. I know now how to circumvent this bug without the external dependencies. Just write NifSkope.bat, place it next to NifSkope.exe and associate .nif files to it:

@echo off
C:\Games\ModOrganizer\ModOrganizer.exe C:\Games\ModOrganizer\mods\NifSkope\NifSkope\NifSkope.exe ""%*""

There. Problem solved :D Not sure why the double quotation marks are necessary (could be a bug down the chain and not in the script as speculated above) but as long as it's working I'll bite the bullet and call it mea culpa :D

 

Regardless, Thanks! I guess you could add this trick in the wiki since for most people it solves the big problem of associating files to creative kit? I think it should also allow passing arguments - such as fullproc - and the like...

Edited by g96968
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Guidelines, Privacy Policy, and Terms of Use.