I'm going to use an issue I'm having with a Java application to explain my question by way of an example, but this question has nothing really to do with Java.
I'm using Windows 7 (64-bit) and I want to create a Start Menu shortcut to execute a GUI Java application. As of Java 8, the installer puts NTFS symbolic links in a well-known place pointing to a release-specific (i.e. subject to frequent change) directory:
C:\>where javaw
C:\ProgramData\Oracle\Java\javapath\javaw.exe
C:\>dir C:\ProgramData\Oracle\Java\javapath\javaw.exe
Volume in drive C is OS
Volume Serial Number is D4DC-33AF
Directory of C:\ProgramData\Oracle\Java\javapath
05/03/2015 15:40 <SYMLINK> javaw.exe [C:\Program Files\Java\jre1.8.0_40\bin\javaw.exe]
I created a shortcut whose target command line was C:\ProgramData\Oracle\Java\javapath\javaw.exe java_app.jar but when I run it, Windows says the javaw.exe path does not exist. I can successfully run the same command line from the Windows Run dialog; just not from a shortcut. Can anyone offer a solution? (I prefer not to create a batch file to run the command, as that would create a useless console box.)
(NB You can also see the same issue without using Java. Just create a symbolic link to Notepad.exe (using the MKLINK command) and then try to create a shortcut to the symbolic link.)
You can still do the useless batch file. Use CALL inside of it so the console window closes immediately after starting your application.
Also, not on Windows machine right now, but can you create a shortcut to CMD.exe
instead and pass your command in there? You may do it in conjunction with CALL
in case console window appears.