Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Tricky MS-DOS command line parameter thing...


  • Please log in to reply

#1
Jack W-H

Jack W-H

    Member

  • Member
  • PipPip
  • 86 posts
Hello! Sorry if this is quite an obvious answer... I'm still new to this sort of stuff... :)

OK, I'm left with a slight problem. I just can't do this whole command line business!

What I'm making is a toolbar for someone, for their web browser. Everything works and I've got a software package to make the main part of the toolbar for me.

But I need a button that can launch his BitTorrent client program.

The software package only allows you to, when trying to open an exe, specify two things: 1) The Exe name, and 2) any parametres to go with it.

The problem is that I don't know which BitTorrent client he's got. So I know that I can fathom it out like this:

1) Set the exe name as "cmd.exe" to open up the command line...

2) Put this is as the parametre values:

/k ftype BitTorrent

By putting that in, it pops up the Command Line and shows that BitTorrent files are associated with the program (in my case, my download manager, FlashGet - so for me it says "BitTorrent = "C:\Program Files\FlashGet\FlashGet.exe" "%1".

The problem I'm facing is how to get the computer to fathom out what his BitTorrent client is (solved), BUT THEN launch it, all in one Parameter line!

If anyone could tell me how to do this, then I'd be very appreciative

Thank you!
  • 0

Advertisements


#2
TomWij

TomWij

    Member

  • Member
  • PipPipPip
  • 125 posts
Why don't you write a batch file that you call?
/k C:\Batch.Bat BitTorrent
Let that batch file do the ftype and get the "C:\Program Files\FlashGet\FlashGet.exe" out of it, put that in a variable and run the variable.

Use google to learn how to do text processing and how to store things in a variable, etc...
You could also download a win32 version of the linux grep and cut if you know those commands.
  • 0

#3
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP

ftype BitTorrent

This already won't work if your user has a different distribution -- I use uTorrent and 'ftype BitTorrent' returns nothing on my system.

You want to use 'assoc' to get the association with .torrent files, and then get the command line with ftype.

The right way to do this is by looking up the associations in the registry, but if you are dead-set on using built-in command-line tools only, try this:

for /f "tokens=2 delims==" %a in ('assoc .torrent') do (for /f "tokens=2 delims==" %b in ('ftype %a') do @echo %b )

Note that if you are going to put this in a batch file you will need to double the %'s.

But this is ugly. Why wouldn't you simply be able to open your .torrent file directly, with whatever you are using to spawn cmd.exe, and let Windows take care of looking up the appropriate associations?
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP