Favorite/File(executable), how to specify working directory?

I have some executable files I’d like to add to favorite, however, when I start them from listary’s popup menu, their working directories were not set to where the executable files because these executables cannot load files expected in the same directories as the executables.

In Windows shortcut properties dialog, there is a “Start in” text box where I can specify the working directory for the executable, but listary’s favorite details only have “Path” for the executable, is there any way I can set the executable’s working directory?

Thanks.

Hello cameos,

Sorry that specifying working directory is not possible with the current version of Listary. I’ll work on it after finishing Listary 4.

As a workaround you can probably make a windows batch file that will change to apt directory and then run the application.
Also, you can write simple Autohotkey application, but this is a little more complicated.

Also, you can write simple Autohotkey application, but this is a little more complicated.

In fact, this is a super simple task :slight_smile:

your_app.ahk
Run, “path\file”, path

Fill in your path + executable (file.exe) and don’t put the path for the working dir (after the second “,”) into double quotes! Compile it, done.

Compile it
This is why I considered it as "more complicated". ;)

I made a simple application that will set working directory to where the executed application is located. Does that help? I didn’t test it with Listary but it worked in command prompt.

http://daroc.ovh.org/listary/runner.zip

Usage: runner.exe c:\path\to\your\app.exe
This will set working dir to c:\path\to\your and run c:\path\to\your\app.exe
Note: you should use quotes if the path or file name contains spaces.

Edit: This method does not seem to work as Listary doesn’t pass parameters.

Thanks everyone. It seems that 4.0 will have lots of improvements and I am really looking forward to it.

@cameos

Do you need a different working dir (than the folder where the application’s executable resides)? I could write a small script (which I would compile), that uses a .ini file where you could enter a specific working directory.

Here is my little starter:
http://dl.dropbox.com/u/4476281/Runner.zip

Extract it wherever you want and edit the Runner.ini to your needs. Just take a look at the demo entries that I made. The only thing that you need to do afterwards: Call this Runner.exe from Listary.

If no .ini file is found it will create a new one for you (and open it with notepad).

The code from the script (if you want to compile it for yourself to change the icon):
#NoEnv
#NoTrayIcon
#SingleInstance force

; #SETTINGS# ====================================================================================================================
iniFullPath := A_ScriptDir . “\Runner.ini”

; #MAIN PART# ===================================================================================================================
Gosub, _CheckForIniFile
Gosub, _CheckForApplication
Gosub, _StartApplication
ExitApp

; #FUNCTIONS# ===================================================================================================================
_StartApplication:
Run, “%Application%”, %WorkingDir%
Return

_CheckForApplication:
; Check for application
If (FileExist(Application) = “”){
MsgBox, %Application% not found, aborted!
ExitApp
}
Return

_CheckForIniFile:
; Check for .ini file
If FileExist(iniFullPath){
IniRead, Application, %iniFullPath%, General, Application, NotFound
If (Application = “NotFound”){
MsgBox, Key: “Application” not found, check your %iniFullPath%!
ExitApp
}
IniRead, WorkingDir, %iniFullPath%, General, WorkingDir, NotFound
If (WorkingDir = “NotFound”){
MsgBox, Key: “WorkingDir” not found, check your %iniFullPath%!
ExitApp
}
} Else {
MsgBox, %iniFullPath% not found, will be creating a default one now…
IniWrite, <filename>.exe, %iniFullPath%, General, Application
IniWrite, , %iniFullPath%, General, WorkingDir
Run, “%A_WinDir%\system32\notepad.exe” "%iniFullPath%"
ExitApp
}
Return

Thank you very much @highend and @daroc for the tips!

To be honest, you have to put that working directory into you ini file, so why do you think it’s better/different than/to just two or three lines of batch file? :wink:

What’s wrong with it, if he wants to specify a completely different working directory?

If all of his working directories are always the folder where the main executable is placed, I have no problems to remove that part from the script so that the compiled .ahk script evalutes the right folder by itself.

A few lines in a batch file?

| Edit: This method does not seem to work as Listary doesn't pass parameters.
How does the batch script find out which .exe it should start if Listary doesn't pass any parameters to it?

Apart from that: If the OP doesn’t want to have a visible dos command prompt he has to compile it or use other methods to hide it (hstart.exe for example).

If all of his working directories are always the folder where the main executable is placed, I have no problems to remove that part from the script so that the compiled .ahk script evalutes the right folder by itself.
So it's the same as executing it in batch file. But does not require complication.
How does the batch script find out which .exe it should start if Listary doesn't pass any parameters to it?
How does AHK script find out which .exe it should start? You specify it in ini file using Notepad. The same way you specify exe to run in you batch file.
Apart from that: If the OP doesn't want to have a visible dos command prompt he has to compile it or use other methods to hide it (hstart.exe for example).
start /b app.exe

To make it clear: I’m not saying that your method is wrong or something. I just thought that if there’s no way to make an universal script that would take an argument (to tell which exe to run), there’s no point in writing 50-line script and compile it using additional software if you can do the same using just windows bat file.

| start /b app.exe

You can’t invoke a start /b app.exe from Listary, right? So how do you call your .bat file from listary without invoking a command prompt window?

If you run “start” command in the bat file, the command prompt will show for less than second and disappear, even though the application ran by “start” command is still open and running.

So you still get a command prompt (even for less than a second). I don’t like such a behavior but it’s just me. Let’s see what the OP really wants / needs / doesn’t like to see.