How can I have a script detect where it's being run from in a graphical file manager? For instance, I want to run a Windows program in a directory with Wine by double clicking it in Nautilus, but Wine fails to load the DLL files because it isn't treating the file manager's open folder as the current working directory. It assumes it's being run from my home directory.
Edit for clarity:
In this example I'm not trying to detect where the wine executable I'm running is. Suppose in my file manager I have
/home/test-directory/win open and I'm trying to run
I'm looking for a way to wrap the Wine command in a shell script so I can have it automatically change into
/home/test-directory/win before attempting to run wine on
testprogram.exe. If I was in
/home/other-directory/win, I want it to automatically change into
/home/other-directory/win instead before running.