# Tricky command line thingy, can I have some help?



## Jawah (Apr 4, 2008)

Hello!

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!

EDIT: I know you say don't post about BitTorrent, etc... but, this doesn't really involve USING BitTorrent or whatever... it'd be just the same if it was Microsoft Word... ? Sorry, delete this if you have to...


----------



## TheOutcaste (Aug 8, 2007)

```
/k for /f "tokens=1,* delims==" %I in ('ftype bittorrent') do start %~dpnJ.exe
```
Note: This will only work if the file type bittorrent is associated with his client; not all clients set up that association.
Also, the path returned must not contain a variable.
For example *ftype txtfile* gives txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1
the start command then becomes *start c:\%SystemRoot%\system32\NOTEPAD.exe*
%SystemRoot% doesn't get expanded, and if it did, the drive letter would not be needed.
You can do one path format or the other, but I haven't gotten it to work reliably with both types.
If you can start a batch file instead of an exe file, this can be checked easily.

Jerry


----------



## Jawah (Apr 4, 2008)

Working... well, sort of...

It's very close, just a little bit of an error now. When running cmd.exe with the parameters you specified, the command line window pops this up:

"Windows cannot find 'C:\Program'. Make sure the name you typed blah blah blah"...

As you say, I would do it in a batch file but the way the toolbar software works limits you from doing this...

The final output on the DOS screen is this (after clicking OK on the cannot find dialog)...


```
C:\PROGRA~1\SOFTOM~1\TOOLBA~1\projects\cab.in.work>start C:\Program Files\FlashGet\FlashGet.exe
The system cannot find the file C:\Program.

C:\PROGRA~1\SOFTOM~1\TOOLBA~1\projects\cab.in.work>
```
Thanks for the help so far though...


----------



## TheOutcaste (Aug 8, 2007)

Dang, hate when I forget the durned quotes. Seems I always pick folders without spaces so I never notice. Try this:
*


Code:


/k for /f "tokens=1,* delims==" %I in ('ftype bittorrent') do start [COLOR="Red"]"[/COLOR]%~dpnJ.exe[COLOR="Red"]"[/COLOR]

*Jerry


----------



## Jawah (Apr 4, 2008)

Almost there... 

What happens now:

Two windows open - the first window:

First window titled "C:\WINDOWS\system32\cmd.exe"
Contents of window (same as last time but without the error):

```
C:\PROGRA~1\SOFTOM~1\TOOLBA~1\projects\cab.in.work>start C:\Program Files\FlashGet\FlashGet.exe

C:\PROGRA~1\SOFTOM~1\TOOLBA~1\projects\cab.in.work>
```
Then there's a second window, titled "C:\Program Files\FlashGet\FlashGet.exe"
Contents of window:

```
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\PROGRA~1\SOFTOM~1\TOOLBA~1\projects\cab.in.work>
```
And then, no program actually opens... 

Sorry this is dragging on a bit longer than I guess it should...


----------



## TheOutcaste (Aug 8, 2007)

Check the shortcut that starts the program. Perhaps there is a command line switch that needs to be specified.
If you open a command prompt, can you start the program by entering:
*start C:\Program Files\FlashGet\FlashGet.exe*
or just
*C:\Program Files\FlashGet\FlashGet.exe*
If neither work, try first switching to the program folder
*cd C:\Program Files\FlashGet*
and see if it will start then. Could be the program is looking for it's configuration file in the current folder which it expects to be *C:\Program Files\FlashGet*, but the current folder is actually *C:\PROGRA~1\SOFTOM~1\TOOLBA~1\projects\cab.in.work*

Jerry


----------

