...

View Full Version : open .exe



p3x
12-15-2004, 09:05 PM
Hello,

I have a HTML file from which I must open an .exe with an argument (the argument being an url). The problem is also that the .exe is not always located in the same place. It is however always located in the same place as the html file is.

How could I get this to work in Javascript?

Thanks in advance
p3x

A1ien51
12-15-2004, 09:23 PM
make the link to the exe relative...

p3x
12-15-2004, 10:15 PM
Ok, thanks for that suggestion. That still doesn't tell me how I can open an .exe from javascript :) Could you pls help me with that as well?

jbot
12-15-2004, 11:02 PM
<a href="#" onclick="location.href='file.exe'; return false" target="_blank">open file</a>

the critical part is the red text :)

glenngv
12-16-2004, 04:02 AM
I have a HTML file from which I must open an .exe with an argument (the argument being an url).
You should look into WSH and HTA for this.

p3x
12-16-2004, 09:56 AM
I looked into WSH, like you suggested and I found a way to open the .exe with a parameter:

test.html contains this: (amongst other things)

var myshell = new ActiveXObject( "WScript.shell" );
myshell.run( ' "c:/testfile.exe" '+varUrl+' ', 1, true );

That works perfect to open testfile.exe with the varUrl as parameter. The only problem now is that testfile.exe is not always in C: root, it IS always in the same location as test.html. So somehow I have to replace C: with something variable...any ideas?

P3x

jbot
12-16-2004, 10:28 AM
The only problem now is that testfile.exe is not always in C: root, it IS always in the same location as test.html. So somehow I have to replace C: with something variable...any ideas?

then surely you can just drop the drive identifier from the file path:


myshell.run( ' "testfile.exe" '+varUrl+' ', 1, true );

p3x
12-16-2004, 10:58 AM
well, tried that - and it seems that 'desktop' is the current directory. But that is NOT the directory the .exe is located... so that doesn't seem to work
:(

jbot
12-16-2004, 11:07 AM
you'll need to run a script to get the current drive and directory and then prepend that to the filename you're calling.

ez4ne12c
12-16-2004, 11:33 AM
if you are using activeX why dont you just get the currrent folder name?
//Determine the installed path
my_path = location.pathname;
my_path = my_path.substr(1,(my_path.lastIndexOf('\\')));
my_folder = XObject.GetFolder(my_path);

where XObject is whatever you call your activeX FileSystemObject
ez

codegoboom
12-16-2004, 03:42 PM
That's about it for IE, although there's no reason to get the folder object.

An HTA is different. It allows for relative links with most MS automation objects, and has the commandLine property for getting a current path.

Script files are different as well, having ScriptFullName & ScriptName properties.

Unless you are willing to disable browser security settings, an HTA is probably what you're after.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum