Pass cmd.exe arguments via a shortcut?

9,519

Solution 1

Ok by following this... http://www.windowsitpro.com/article/registry2/how-can-i-open-a-command-prompt-at-my-current-directory-in-explorer-.aspx?cpage=2

I got as far as this... http://dl.dropbox.com/u/497583/code/livereload.reg [EDIT] The above file works just fine now. I just need && to seperate commands.

But I need to know how to pass it further commands like "livereload". Also it opens on the folder you're currently in and not the folder you have right clicked.

Solution 2

use this :

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\livereload] 
@="Livereload" 

[HKEY_CLASSES_ROOT\Directory\shell\livereload\Command] 
@="cmd.exe  /E:ON /K C:\\Ruby191\\bin\\setrbvars.bat  & pushd %L & @livereload"

works for me... you can edit @="Livereload" to change what it says in the context menu

Solution 3

When you create a batch file (.bat). Any thing that is dragged and dropped will infact turn into a command line parameter.

You can access these parameters with a %1, %2, %3... etc

So in you case ...So basically it is running cmd, launching ruby, passing in the directory and activating livereload...

in your bat file (assuming your ruby stuff is properly in your path)

@echo off
echo %1
ruby myScript.rb %1
EXIT

then all you would need to do is drag and drop that directory onto the script and all will run properly

Share:
9,519

Related videos on Youtube

firefusion
Author by

firefusion

Updated on September 17, 2022

Comments

  • firefusion
    firefusion over 1 year

    I'd like to create a shortcut to run cmd at a particular location with a few commands.

    I'm hoping from there I can work out how to make it a right click option to "Run my cmd commands here..."

    I've found the shortcuts to run CMD with ruby. Which is part of what I want. C:\Windows\System32\cmd.exe /E:ON /K C:\Ruby191\bin\setrbvars.bat

    Then in the target field I set me location. Now I just need to know how to pass it some startup arguments.

    It is basically to help me run livereload easily on folders. LiveReload is a mini webserver/ruby gem that will auto refresh the browser when you save changes to files contained within the folder you're running it in https://github.com/mockko/livereload

    So basically it is running cmd, launching ruby, passing in the directory and activating livereload.

    • NVI
      NVI about 13 years
      I'm one of the developers of LiveReload. I'd like that to. You would also need to somehow show all enabled directories. And an option to stop it.
    • firefusion
      firefusion about 13 years
      I found the fix. See my answer.
  • firefusion
    firefusion about 13 years
    Ok, I fixed it and the above file works now!
  • freshWoWer
    freshWoWer over 12 years
    Would you mind telling me where did you find the use of %L or explanation page ? i know %L give the whole path, is there another variable, if I just want the current directory name, without the whole path?