Michael Dunn wrote:> The problem I'm having is that I'm trying to figure out how to make Java open a shortcut link in Windows.
if you just want to open whatever the link is to, use Runtime
to get the info from the link, you could create a vbscript file to do that, run it from java and have it return the data,
but it gets a bit messy.
Darnell Day wrote:I've googled and found a source of JShortcut here but I don't see any .jar files within the folder, even though it says to "Double click on the jar file", which leaves me very confused.
Darnell Day wrote:Just to post an update, I've been trying to figure out how to implement Jar files into my Java project but I'm not getting any luck. I've googled and found a source of JShortcut here but I don't see any .jar files within the folder, even though it says to "Double click on the jar file", which leaves me very confused. I see that this can create shortcut links, which I will need later and is very useful, but I hope it can retrieve the original path of the shortcut link which is what I ultimately need.
Michael Dunn wrote:> Creating a VBScript file sounds extremely complicated, .... But would you mind explaining a little more in depth of how I would go about doing this?
easier to show you (not many lines)
save this as GetShortcutPath.java
in the *same* folder, save this as GetShortcutPath.vbs
copy into Notepad, make sure it's not saved as GetShortcutPath.vbs.txt
compile and run the .java file, if all done correctly the full path should appear in a JOptionPane
Michael Dunn wrote:> Can I somehow pass this array to the VBScript and make the VBScript return the result back to my java program?
VBScript takes arguments the same way java does.
if you're feeling adventurous, you can get java to write the vbscript file, run it, then delete it.
Michael Dunn wrote:supplying args to a java program run
from the command line is the same with VBScript
Michael Dunn wrote:> how would I get the output to return
> to the Java program?
exactly the same as earlier posts.
Michael Dunn wrote:you've had it working where you run the java program, which then runs the vbscript file,
which, in turn, re-runs the java program, this time supplying the target path as an argument.
the java program works 2 ways, via args > 0
a) if == 0, it runs the vbscript file, and exits
b) args > 0, it is being run from the vbscript file, which is supplying the argument
if you want the java program to write the vbscript file, then delete it -
in (a) this is where you'd write the file, save the file, then run it
you may have to add a small delay (e.g. 500ms) between saving and running
in (b) once the argument has been supplied, the vbscript file can be deleted
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.