We help IT Professionals succeed at work.

hyperlink to a file with parameters

4,329 Views
Last Modified: 2010-04-21
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

Comment
Watch Question

b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
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
Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
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
KoenSDM Mobile
CERTIFIED EXPERT

Author

Commented:
@ 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.
KoenSDM Mobile
CERTIFIED EXPERT

Author

Commented:
another question is similar (i think)
https://www.experts-exchange.com/Programming/Misc/Q_20916522.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...
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
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
KoenSDM Mobile
CERTIFIED EXPERT

Author

Commented:
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
 
IT Consultancy
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
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
KoenSDM Mobile
CERTIFIED EXPERT

Author

Commented:
@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?
KoenSDM Mobile
CERTIFIED EXPERT

Author

Commented:
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!
KoenSDM Mobile
CERTIFIED EXPERT

Author

Commented:
Excellent solution !
Steve KnightIT Consultancy
CERTIFIED EXPERT

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

Steve

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.