Hyperlink with Command-line Switch

B

barneybeale

I'm generating an email in vb6 which contains a hyperlink to an exe
file and a command-line switch.

Outlook receives the email, and the hyperlink works to the exe file, eg
"C:\Program Files\Microsoft Office\Winword.exe".

The problem is with adding the command-line switch to the hyperlink, eg
"C:\Program Files\Microsoft Office\Winword.exe c:\myfile.txt"

I've tried combinations of quotes, brackets, %20, and even plain text,
rich text, and html email formats. None of these seem to work.

Can anyone suggest what needs to be done to get this working, if indeed
it can actually be done?

Thanks
 
P

Pegasus \(MVP\)

I'm generating an email in vb6 which contains a hyperlink to an exe
file and a command-line switch.

Outlook receives the email, and the hyperlink works to the exe file, eg
"C:\Program Files\Microsoft Office\Winword.exe".

The problem is with adding the command-line switch to the hyperlink, eg
"C:\Program Files\Microsoft Office\Winword.exe c:\myfile.txt"

I've tried combinations of quotes, brackets, %20, and even plain text,
rich text, and html email formats. None of these seem to work.

Can anyone suggest what needs to be done to get this working, if indeed
it can actually be done?

Thanks

The line

"C:\Program Files\Microsoft Office\Winword.exe c:\myfile.txt"

is certainly wrong - it would attempt to execute "myfile.txt"! If
it works at all then it might have to look like this:

"C:\Program Files\Microsoft Office\Winword.exe" c:\myfile.txt
 
S

Sneha Menon

I'm generating an email in vb6 which contains a hyperlink to an exe
file and a command-line switch.

Outlook receives the email, and the hyperlink works to the exe file, eg
"C:\Program Files\Microsoft Office\Winword.exe".

The problem is with adding the command-line switch to the hyperlink, eg
"C:\Program Files\Microsoft Office\Winword.exe c:\myfile.txt"
I've tried combinations of quotes, brackets, %20, and even plain text,
rich text, and html email formats. None of these seem to work.

Can anyone suggest what needs to be done to get this working, if indeed
it can actually be done?

Thanks
---------------------------------------------
Hi barneybeale

I could not fully understand the set up. Anyway here is a blind shot
instead of %20 try %1
and let me know the result

Sneha
--------------------------------------------
 
I

indyblue

%1 gives the same results as %20. i.e. it reads the whole line as a
single command, rather than an executable with a parameter after it.
Consequently Windows says that it cannot find the file.

Usually a space separates the executable path from the parameter and
that works fine in a shortcut (eg on the desktop), but not in a
hyperlink inside an email.
 
I

indyblue

Pegasus,

That was a mistake in my typing of the original message. I am indeed
trying to get something like this to work via a hyperlink in an email:

"C:\Program Files\Microsoft Office\Winword.exe" c:\myfile.txt
 
E

expvb

I'm generating an email in vb6 which contains a hyperlink to an exe
file and a command-line switch.

Outlook receives the email, and the hyperlink works to the exe file, eg
"C:\Program Files\Microsoft Office\Winword.exe".

The problem is with adding the command-line switch to the hyperlink, eg
"C:\Program Files\Microsoft Office\Winword.exe c:\myfile.txt"

I've tried combinations of quotes, brackets, %20, and even plain text,
rich text, and html email formats. None of these seem to work.

Can anyone suggest what needs to be done to get this working, if indeed
it can actually be done?

Thanks

Without seeing your code, it's hard to guess. Try one of the following:

s = Chr(34) & "C:\Program Files\Microsoft Office\Winword.exe" & Chr(34) & "
c:\myfile.txt"

Or:

s = URLEncode(SomeText)

URLEncode function can be found in many places. Here is one:

http://www.freevbcode.com/ShowCode.asp?ID=1512
 
S

Sneha Menon

I'm generating an email in vb6 which contains a hyperlink to an exe
file and a command-line switch.

Outlook receives the email, and the hyperlink works to the exe file, eg
"C:\Program Files\Microsoft Office\Winword.exe".

The problem is with adding the command-line switch to the hyperlink, eg
"C:\Program Files\Microsoft Office\Winword.exe c:\myfile.txt"
----------------------------------------------------------------
Hi Barney

As far as Word or Notepad or any Browser application is concerned

Shell "C:\Program Files\Microsoft Office\Office10\Winword.exe
c:\myfile.doc", vbNormalFocus

Shell "C:\Windows\Notepad.exe c:\someFile.txt", vbNormalFocus

Shell "C:\MyFolder\MyOwnBrowser.exe www.google.com", vbNormalFocus

are perfectly alright. I am trying them here, work fine
(Pegasus said it is definitely wrong; He is wrong)

I am not sure about Outlook and Email things.

I am posting this taking other posters' surmise at face value
As I said in my first posting, I am still not sure about your actual
requirement

Regards

Sneha
-----------------------------------------------------------------------
 
P

Pegasus \(MVP\)

Sneha Menon said:
----------------------------------------------------------------
Hi Barney

As far as Word or Notepad or any Browser application is concerned

Shell "C:\Program Files\Microsoft Office\Office10\Winword.exe
c:\myfile.doc", vbNormalFocus

Shell "C:\Windows\Notepad.exe c:\someFile.txt", vbNormalFocus

Shell "C:\MyFolder\MyOwnBrowser.exe www.google.com", vbNormalFocus

are perfectly alright. I am trying them here, work fine
(Pegasus said it is definitely wrong; He is wrong)

You overlook a mintor detail. The OP had a space in the
path that leads to his executable. You don't. Now try to
rename "MyFolder" to "My Folder", leave all the quotes in
place, then see what happens and tell me if I'm still wrong!
 
B

Bob Butler

I'm generating an email in vb6 which contains a hyperlink to an exe
file and a command-line switch.

Outlook receives the email, and the hyperlink works to the exe file,
eg "C:\Program Files\Microsoft Office\Winword.exe".

The problem is with adding the command-line switch to the hyperlink,
eg "C:\Program Files\Microsoft Office\Winword.exe c:\myfile.txt"

AFAIK, you can't. Using %20 in place of spaces will let it be recognized as
a single string but then won't execute correctly while using a space will
let it execute correctly but won't let it be recognized as a single string.
I've tried to do something like this in an ASP page and never could find a
workable solution.
 
S

Sneha Menon

Pegasus said:
You overlook a mintor detail. The OP had a space in the
path that leads to his executable. You don't. Now try to
rename "MyFolder" to "My Folder", leave all the quotes in
place, then see what happens and tell me if I'm still wrong!
----------------------------------------
On two counts.

What difference it make between My Folder and MyFolder?
Haven't you ever seen windows New Folder? Why go for New Folder!!
Almost all Exe files are inside Program Files. Can't you see a space
between Program and Files?

According to your argument an Exe file inside New Folder or Program
Files should not Work.

In your original posting you didn't complain about any space. You just
took the Commandline thing out of the quotes. Can You make it work?

When I said that is wrong, only to argue with me you dug up the space
issue
that is also utterly wrong. You are sitting in front of a computer; it
is a matter of keying in 10 lines of code. Why can't you try it there?

Just to satisfy you, I tried My Folder here. It is just the same as
before.

(Count two? Argument based on wrong premises)

Sneha
-----------------------------------------------------------------------------------------
 
I

indyblue

The URLencode function removes the spaces (or rather it replaces them),
but Outlook doesn't recognise any of it as a hyperlink now.

I tried creating an HTML formatted email, with the encoded URL as the
target behind a link. Outlook now recognises the link, however clicking
on the link opens my browser (IE) and returns an "Invalid Syntax Error,
The page cannot be displayed - The page you are looking for might have
been removed or had its name changed."
 
I

indyblue

Thanks Bob - you seem to know exactly what I'm after. Shame it looks
like it can't be done though.
 
E

expvb

indyblue said:
The URLencode function removes the spaces (or rather it replaces them),
but Outlook doesn't recognise any of it as a hyperlink now.

I tried creating an HTML formatted email, with the encoded URL as the
target behind a link. Outlook now recognises the link, however clicking
on the link opens my browser (IE) and returns an "Invalid Syntax Error,
The page cannot be displayed - The page you are looking for might have
been removed or had its name changed."

There is no code posted, so I can't understand what you are trying to do.
 
B

Bob Butler

expvb said:
There is no code posted, so I can't understand what you are trying to
do.

For my part I was trying to do something similar from a web page

<a href="myapp.exe arg1">Click here to run app for arg1</a><br />
<a href="myapp.exe arg2">Click here to run app for arg2</a><br />

I could not find any way without using client-side scripting to get a
hyperlink to run an app with a command line argument.
 

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

Top