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 am currently trying to create a context menu item so that you can click on an executable file and select a scan option from the context menu, a command line program will then be launched with the working directory defined as C:\Program Files\Scanner and the input file (file I right-click on) will be the insert in the %1% parameter.

[HKEY_CLASSES_ROOT\exefile\Shell\Scan\command]
@="C:\\Windows\\System32\\cmd.exe /k cd  "C:\\Program Files\\Scanner" & "C:\\Program Files\\Scanner\\scanner.exe" "%1%""

I am having a nightmare trying to get this work, any help would be greatly appreciated

share|improve this question

1 Answer 1

up vote 1 down vote accepted
  1. It's %1, not %1%

  2. You must also escape the inner quotation marks:

    [HKEY_CLASSES_ROOT\exefile\Shell\Scan\command]
    @="cmd.exe /k cd /d \"C:\\Program Files\\Scanner\" && scanner.exe \"%1\""
    
  3. The /d option must be given to cd, to also change the current drive letter in cmd (if your file is on another drive).

  4. Specifying full path to scanner.exe is not necessary, because after you cd it will be in the current directory.

share|improve this answer
    
Thanks, saved me a lot of hassle :) –  James Jun 5 '11 at 23:12
    
@James: One thing I forgot. You must use cd /d, not cd, otherwise the command will fail when the file is on another drive. –  grawity Jun 6 '11 at 12:13

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.