Link to home
Start Free TrialLog in
Avatar of Koen
KoenFlag for Belgium

asked on

hyperlink to a file with parameters

Here goes:

My application (HPOVSD) sends out a notification (email) that a new item (ticket) has arrived.
I also have a bat file (on each local machine) that will open this item.
c:\path\sd_formdata.bat servicall "ID=1234"
I want to launch this bat file (opening the new item) from within that mail with (of course) the 1234 being a variable, namely the ticket in question.

I've created a new .bat file, named, launch.bat, basically with the cmd:
c:\path\sd_formdata.bat servicecall %1

Now in the mail I can reference to this using a hyperlink:
File///c:path\launch.bat
not passing the ID results (thus works fine) in a list of all tickets
but I want/need to pass the variable to only open the ticket itself

in a dos box, i type launch.bat "id=1234"
resulting in the correct ticket to open

so how do i pass this variable (through the hyperlink) to the bat file.

tx a million

Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

The mail program security will almost certainly prevent what you are trying to do.  What is the specific email program you use?  Which version?  Most current browsers prevent pages from accessing local files, unless it is a local file, and email programs are even more cautious.

If the email program allows some windows scripting then you might use it to access the shell to do this.  This will completely depend on the program you use though and is usually prevented by security.

Let me know if you have a question about any of this.

bol
The file:// url handler won't pass this on.  All I can suggest is that rather than writing a url into the email as a link instead send a .cmd .vbs or .bat file which has been custom output by your app, i.e. it can be:

@echo off
call c:\path\sd_formdata.bat servicecall xxxx

And is written out by your application but as has been said above unless this is a fixed internal environment that you control it is most likely to be blocked.

Thats why I love Lotus Notes.... secure, signed emails sent out from my apps in any format I like to users with buttons etc. running whatever code I choose... but only those we choose to allow through the ECL.

Steve
Avatar of Koen

ASKER

@ bOIsc0tt:

the reference in the e-mail works to launch the cmd. It just won't pass the argument

@ dragon_it

exchange wont allow me to send .cmd, .bat or vbs files... and sending it as txt and having the user 'save as' it, looses the intent of making it easy to the user.
Avatar of Koen

ASKER

another question is similar (i think)
https://www.experts-exchange.com/questions/20916522/Send-a-path-of-Exe-with-parameters-in-a-hyperlink.html

and wants me to send in a e-mail this code

Start My Program

<script language="javascript">
function runapp()
{
var ws = new ActiveXObject("WScript.Shell");
ws.Exec("notepad.exe c:\\zx.htm");
}
</script>

where of course the notepad.exe would be replaced by a string, built from the application + the variabel

but I don't see how this would work...
I am surprised it is working.   I can't think of any way to pass an argument so the batch file would get it.  It doesn't read the query string but if you try to use a space, etc then the browser won't bring up the right file.  It is sort of a catch 22. :)

The javascript you found would work if your email program will allow an ActiveX object.  That is an MS technology so generally just supported by IE and other MS programs, at least natively.  Did you try using it with a change to the ws.Exec line like ...

ws.Exec("c:\path\launch.bat ID=1234");

Let me know how that works.  There won't be too many other options if your email program doesn't support ActiveX.

If that doesn't work and you want to know about possible options then we do need to know what email program you use to read the message.

bol
Avatar of Koen

ASKER

the mail system is exchange and outlook is the client (version 2007)
the mail is generated bu the application (HPOVSD) and is smtp email.

i can send hyperlinks (e.g. an email address or URL) because outlook interpretes the (plain) text send by the application and tags and formats it as a link.

however the java code is not recognized, at least not in the form it is presented above, so the mail just shows the code, but it doesn't do anything
 
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For the Javascript solution to work you have to make sure the message is sent as an HTML one, with full html tags.  A plain text or even rich text message would not work.  You could look at the headers of the message you are currently sending to confirm this is the problem.  Of course Outlook may still prevent the script.

Unfortunately Outlook does not make it easy to send a real html message.  If the suggestion above doesn't work and you want to try to send an html message with Outlook to test the Javascript then let me know.  I can work on getting you details. :)

bol
Avatar of Koen

ASKER

@bOIsc0tt

Yes, I understand, but that is not possible... I can't change the application that generates the email nor the format it sends it in.

@dragon-it:
This is making progress...!
just one problem still remains: the parameter that I need to pass is : "ID=1234" (including the quotation marks)
putting them in the hyperlink changes the parameter to %22ID=1234%22 being passed to the bat file.

Any ideas on how to deal with that?
Avatar of Koen

ASKER

never mind my last post...
i got around that by putting the "ID=%1" in the local bat file, so I only need to pass the number!

Great work, dragon-it, the points are absolutly yours!

Thanx a million!
Avatar of Koen

ASKER

Excellent solution !
No problem, glad it worked.... Ok for a closed group on LAN at least where you can install stuff.

Steve