Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to create a shortcut for a command line tool, so that when I drag files onto it, it will pass the filename to the tool as part of the command line arguments (with quotations around it or whatever so that paths with spaces work), and then keep the terminal open after it has finished. Specifically:

cmd /k "C:\Program Files (x86)\SRecord\bin\srec_info.exe" "%<something goes here>" --guess

Is this possible? What goes after the percent sign? What's this called?

share|improve this question

1 Answer 1

%1

This will pass the path to the file.

test.bat:

echo %1
pause

Drag in "C:\Users\user\Desktop\nospaces.exe", result:

C:\Users\user\Desktop\nospaces.exe

Drag in "C:\Users\user\Desktop\file with spaces.exe", result:

"C:\Users\user\Desktop\file with spaces.exe"

So you can write;

cmd /k "C:\Program Files (x86)\SRecord\bin\srec_info.exe" "%1" --guess

and it should receive the path+filename in the same way the bat file did. (See above).

share|improve this answer
    
Ok, that's for batch files, though. Is there a way to do it in shortcuts? –  endolith Feb 8 '10 at 20:22
    
"test.bat %1" and "srec_info.exe %1" should function in the same way. I clarified the answer. –  RJFalconer Feb 8 '10 at 20:32
    
Yes, but I tried that already and it didn't work. :) I can use a batch file, though. –  endolith Feb 9 '10 at 15:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.