Click to See Complete Forum and Search --> : opening file with a command line?


NeedAJob
03-03-2004, 12:11 PM
I'm trying to open a file via a piece of JavaScript, I want to be able to pass in a command line switch to be able to start the exe in a certain manner. This is part of the code I'm using;

onClick="window.navigate('setup/setup.exe')" >Start

I've tried

onClick="window.navigate('setup/setup.exe /L1033')" >Start

but the browser then tries to navigate to /L1033, I think I can use an escape character but my knowledge of JavaScript is very low and the tutorials I've looked at (suprise, suprise) don't cover this!

This is a piece of legacy code that I just want to enhance slightly.

I've tried searching the archives but haven't had any luck. All help\suggestions appreciated.

crh3675
03-03-2004, 12:23 PM
onclick="window.open('file://c:\\yourpathtoexe.exe',appwin,'width=100,height=100');return false"

NeedAJob
03-03-2004, 12:31 PM
Thanks for the quick reply but that piece of code fails with not knowing what appwin is, if I remove that it still tries to navigate to the non existent L1033 page.

?

crh3675
03-03-2004, 12:53 PM
My bad, put some quotes around appwin:


onclick="window.open('file://c:\\yourpathtoexe.exe','appwin','width=100,height=100');return false"

NeedAJob
03-03-2004, 01:10 PM
OK, that code now works but gives me exactly the same problem as when I reported it. Maybe if I can explain better...

I have an app that takes command line parameters in this form (imagine myapp takes a switch L for language):

myapp.exe /L1033

if I wanted to fire that from JavaScript I would put this:

onClick="window.navigate('myapp.exe /L1033')"

This causes the browser to attempt to open /L1033 (because it thinks its part of a directory structure) instead of opening myapp.exe and passing /L1033 as a parameter.

crh3675
03-03-2004, 02:09 PM
You won't be able to do that with HTTP unless you have Shell access and execute it from the browser using an ActiveX control. However, if you have your exe setup to parse query variables, it can be done.

crh3675
03-03-2004, 02:32 PM
Here is a WSH example:



function LoadApp(path){

wsh = new ActiveXObject("WScript.Shell");

wsh.Run(path);
}
</script>

NeedAJob
03-04-2004, 03:54 AM
Craig,

Many thanks for your reply and time much appreciated ;) I'll look at the WSH. :)