General Computing
windows environment-variables launcher application-launch
Updated Mon, 18 Jul 2022 20:48:09 GMT

Launch Windows program with custom environment variable

My JAVA_HOME on my dev machine - which is Windows 7 Pro 64 Bit - points to a 64-bit Java, and that's fine in general. However, I just installed a program - to wit, the FlashDeveloper IDE - for which this setting is not fine: a 32-bit Java is required instead, and the JAVA_HOME setting prevents the 32-bit Java from being picked up.

So I'd like to unset JAVA_HOME just before launching the Flash IDE.

One way to achieve this would be via a batch script.

But isn't there a better way? I searched the various tabs of the Windows Shortcut properties window for such an option but there doesn't seem to be any. (I did discover, however, a checkbox for running the program through the shortcut as Administrator.) Any suggestions?

Update: Solution that worked for me

:: type "C:\Program Files (x86)\FlashDevelop\FlashDevelop.bat"
REM Prevent wrong 64-bit JVM from being picked up:
CALL "%~dpn0.exe"

That will open up a command prompt which I can then just close. You can make the shortcut have the icon of the executable you're calling from the command prompt by instructing the shell via the shortcut properties to go looking for an icon inside the actual executable.

I couldn't get the solutions involving START to work, which opens up a new cmd.exe window on my machine when passed the following (no idea why):

start "C:\Program Files (x86)\FlashDevelop\FlashDevelop.exe"

Must say that my cmd.exe is tuned - that might have an influence here and there.

Update regarding the start issue: As can be learnt following the link in the comments, the start command uses the first arguments in quotes as the title of the windows to be created So when you pass a path in quotes, it'll be misinterpreted as the title of the new window. Workaround is to provide an explicit title as first argument, which may also be empty (start "" "some path\with spaces").


Sorry for reviving an old thread, but I figured this could probably help people searching for a solution to this problem:

You can override you JAVA_HOME path directly in your FlexSDK. To do this, navigate to your SDK's bin/ folder (should be in C:\Program Files (x86)\FlashDevelop\Tools\flexsdk\ if you let the FD installer set it up for you, otherwise you probably know where it is) and open jvm.config.

External Links

External links referenced by this document: