Drag and Drop program launch on Windows

P

Phrogz

I want to be able to drag and drop a txt file onto my ruby program,
such that I get the full file path to the txt file in ARGV[0].

I found a page that showed me how to:
a) Create a .bat file with "ruby myprog.rb %1"
b) Create a shortcut to the .bat file with a hardcoded working
directory

But I need to be able to move this .bat/.rb file around and have the
working directory properly updated. (There are support files adjacent
to the .rb that I need to read in.)

Surely there's a better way. Some registry hack to make .rb files
drag-and-drop targets by themselves?
 
P

Phrogz

Well, here's a better way. Still not ideal (where ideal would be
dropping directly onto the .rb itself), but it'll do for now:

D:\<snip>\BindingDocumentation>type MakeDocumentation.bat
pushd %~dp0
ruby MakeDocumentation.rb %1
popd

That will change the working directory to the directory the .bat file
is in, and run the ruby command and pass in the path to the file
dropped on the bat file.
 
A

Alan Chen

Phrogz said:
I want to be able to drag and drop a txt file onto my ruby program,
such that I get the full file path to the txt file in ARGV[0].

I found a page that showed me how to:
a) Create a .bat file with "ruby myprog.rb %1"
b) Create a shortcut to the .bat file with a hardcoded working
directory

You could just put the shortcut in the "Send To" directory. Then it's
just a right-click and send to your script.
 
X

x1

1) Download rubyscript2exe-0.4.0.rb from sourceforge..

2) test ruby script:
# -----test.rb-----
puts ARGV[0]
# -----/test.rb-----

3) run rubyscript2exe-0.4.0.rb test.rb
4) drag a file on the created test.exe

--Alternately, just make an rb script that waits on "gets", then
simply drag the file into the command prompt and hit enter..

dunno.. just some thoughts..


Phrogz said:
I want to be able to drag and drop a txt file onto my ruby program,
such that I get the full file path to the txt file in ARGV[0].

I found a page that showed me how to:
a) Create a .bat file with "ruby myprog.rb %1"
b) Create a shortcut to the .bat file with a hardcoded working
directory
=20
You could just put the shortcut in the "Send To" directory. Then it's
just a right-click and send to your script.
=20
=20
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top