How to pass a dragged filename as parameter in a WinXP shortcut?

C

Cindy Parker

I have problems to pass a dragged filename as parameter to a shortcut to a program.

Lets make a sample for *.jar files but this is a problem for other extensions as well.
Ok I have a executable Java *.jar file e.g. myjava.jar. To run this archive I have to prepend the java
program. So at first I create a shortcut from this *.jar and enter the following command line in the
shortcuts properties:

java -jar D:\java\myjava.jar

Whenever I click now on this shortcut the java and jar prgm are executed successfully.
Fine.

Now I want to pass additionally a filename to the *.jar prgm.

So I changed the command mentioned above in the shortcut to

java -jar D:\java\myjava.jar "%1"

After that I dragged a file foobar.txt onto this shortcut and expected that the java jar
program would run with the filename as parameter:

java -jar D:\java\myjava.jar "D:\test\foobar.txt"

But it doesn't.

Ths filename is somehow not forwarded as parameter.

Whats wrong?

Cindy
 
D

Daniel Pitts

I have problems to pass a dragged filename as parameter to a shortcut to a program.

Lets make a sample for *.jar files but this is a problem for other extensions as well.
Ok I have a executable Java *.jar file e.g. myjava.jar. To run this archive I have to prepend the java
program. So at first I create a shortcut from this *.jar and enter the following command line in the
shortcuts properties:

java -jar D:\java\myjava.jar

Whenever I click now on this shortcut the java and jar prgm are executed successfully.
Fine.

Now I want to pass additionally a filename to the *.jar prgm.

So I changed the command mentioned above in the shortcut to

java -jar D:\java\myjava.jar "%1"

After that I dragged a file foobar.txt onto this shortcut and expected that the java jar
program would run with the filename as parameter:

java -jar D:\java\myjava.jar "D:\test\foobar.txt"

But it doesn't.

Ths filename is somehow not forwarded as parameter.

Whats wrong?

Cindy
Are you sure? What happens when you replace "java -jar" with echo %1?
 
V

VanguardLH

Cindy said:
I have problems to pass a dragged filename as parameter to a shortcut to a program.

Lets make a sample for *.jar files but this is a problem for other extensions as well.
Ok I have a executable Java *.jar file e.g. myjava.jar. To run this archive I have to prepend the java
program. So at first I create a shortcut from this *.jar and enter the following command line in the
shortcuts properties:

java -jar D:\java\myjava.jar

Whenever I click now on this shortcut the java and jar prgm are executed successfully.
Fine.

Now I want to pass additionally a filename to the *.jar prgm.

So I changed the command mentioned above in the shortcut to

java -jar D:\java\myjava.jar "%1"

After that I dragged a file foobar.txt onto this shortcut and expected that the java jar
program would run with the filename as parameter:

java -jar D:\java\myjava.jar "D:\test\foobar.txt"

But it doesn't.

Ths filename is somehow not forwarded as parameter.

Whats wrong?

Cindy

What happens if you remove the "%1" from the command line? As a test, I
created a simple shortcut that ran:

cmd.exe /k echo The file is
(with a trailing space character)

I dragged a file to this shortcut. The full path for the file got
appended to the command line so the echo command printed out:

The file is <pathToFile>
 
R

Roedy Green

java -jar D:\java\myjava.jar "D:\test\foobar.txt"

But it doesn't.

Ths filename is somehow not forwarded as parameter.

You type the name of a bat file on the command line with a parameter.

You can also write a java program that runs and accepts things dragged
to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top