Pass cmd.exe arguments via a shortcut?

4

2

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.

firefusion

Posted 2011-03-12T15:57:30.023

Reputation: 1 703

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. – NVI – 2011-03-14T11:08:59.947

I found the fix. See my answer. – firefusion – 2011-03-16T11:25:04.077

Answers

0

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.

firefusion

Posted 2011-03-12T15:57:30.023

Reputation: 1 703

Ok, I fixed it and the above file works now! – firefusion – 2011-03-16T11:23:29.477

1

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

g19fanatic

Posted 2011-03-12T15:57:30.023

Reputation: 1 251

1

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

brunom

Posted 2011-03-12T15:57:30.023

Reputation: 11

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? – freshWoWer – 2011-11-14T21:33:38.897