Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

The answer is simply:

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

This will pass the path to the file. To test this we can make a simple receiver bat 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 srec_info.exe should receive the path+filename in the same way the bat file did.

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.