Archive: (Advanced?) Registry settings.


(Advanced?) Registry settings.
(This is a bit lengthy to explain, but please bear with me.)
I have a java application that is wrapped in janel to create an executable for ease of use. I have an associated file type that I write to the registry.
The executable works perfectly via clicking on it or using a shortcut.
It doesn't work if you launch it from another directory (i.e. use the command prompt to go D:\> "D:\Stuff\MyProgram.exe").
This is because it's home directory contains property files that it must have to work correctly.
This causes problems for the associated file type, in that if it is not in the install directory it simply doesn't work.
The program will run if a shortcut is used (i.e. you pass the project file to a shortcut instead of the EXE). I have tried to set the registry to use the *.lnk instead of the EXE but that throws an error ("ASW.prjct is not a valid Win32 application)
It will also work if the program is already running (i.e. the program is running and you click on a project file, this will load it in the program)

So these are my questions:

Is it possible to set the registry to move to the required directory and then launch the EXE?

Is it possible to set the registry to launch the program and then send the file to the program?

Is it possible to make the registry work with a link?

Thanks for any and all help you can provide.


Windows allows you to set a file extension to run a batch file.
This batch file example works for notepad which I set up for a "ttb" file extension (just to test it):

C:
notepad %1
exit

This should set the working dir to C:
For the registry entry, it's "path\to\file.bat" %1

-Stu


why not create a application using nsis that acts as a launcher app that sets the current dir and then launces your app

you can also use:
cmd /c "start /Dc:\path\to\my\ c:\path\to\my\app.exe"
in the registry, not sure if this works on Win9x, on those platforms you can use start directly since its a exe (you dont need cmd /c) but im not sure if it supports setting the current dir


Originally posted by Afrow UK
<snip>

-Stu
Unfortunately I need it to run without a command window.

Originally posted by Anders
why not create a application using nsis that acts as a launcher app that sets the current dir and then launces your app
That is just beyond my abilities. And I need to get this done in the next few days. Unless there is some sort of tutorial?
EDIT: Actually, now that I think about it, that would be great. Where could I find out more? (Being honest, I didn't know that NSIS could be used for anything besides installers.)

Originally posted by Anders
you can also use:
cmd /c "start /Dc:\path\to\my\ c:\path\to\my\app.exe"
in the registry, not sure if this works on Win9x, on those platforms you can use start directly since its a exe (you dont need cmd /c) but im not sure if it supports setting the current dir [/B]
It needs to work on Windows and that didn't seem to work.

Extremely simple to do.

Name "ExecShell"
OutFile execshell.exe

Function .onInit

Call GetParameters
Pop $R0

SetOutPath "$EXEDIR"
Exec '"$EXEDIR\program.exe" "$R0"'

Abort

FunctionEnd

Function GetParameters
# this function is in manual!
FunctionEnd

Section
SectionEnd


Minimal script.

-Stu

That's great, thank you all for your help.
Could I set it to compile that script at the time of installation? Or must it be compiled beforehand?


Needs to be compiled before hand obviously, otherwise you'd need to include makensis.exe with your installer and run it with a banner explaining what is happening.
Compile the script and put the exe in as part of your software.

-Stu


Sorry, I forgot that $EXEDIR would get the current directory and couldn't figure out how it was going to get the installation directory.:o
Thanks again.