...

View Full Version : Help Opening an Application from Javascript



jason_kelly
09-29-2011, 04:32 PM
Hello,

I need your help,

I have the following code below, and its giving me an error saying: "The system cannot find the file specified".



<html>

<script language="javascript" type="text/javascript">

function start_ccm(){
var wsh = new ActiveXObject('WScript.Shell');
wsh.exec("C:\Program Files\WorkDynamics Technologies\ccmApplications\ccmMercury.exe")
}

</script>

</head>
<body>
<input id="Button1" onclick="start_ccm()" type="button" value="START" />
</body>
</html>



There is nothing wrong with the location, but my best guess are the spaces in the file path.

Any help with this is greatly appreciated.

Cheers,

J

DanInMa
09-29-2011, 04:37 PM
try this



<html>

<script language="javascript" type="text/javascript">

function start_ccm(){
var wsh = new ActiveXObject('WScript.Shell');
wsh.exec("file:///C|/Program Files/WorkDynamics Technologies/ccmApplications/ccmMercury.exe")
}

</script>

</head>
<body>
<input id="Button1" onclick="start_ccm()" type="button" value="START" />
</body>
</html>

Old Pedant
09-29-2011, 08:26 PM
No, the shell's .exec really does want just a path, not a URL. So using file: would not help.

I think he may be right about the spaces.

Might be able to do this:


wsh.exec('C:\"Program Files"\"WorkDynamics Technologies"\ccmApplications\ccmMercury.exe')

You might note that this kind of path works even in a DOS command prompt.

For example, I just did

cd c:\"program files"
in my DOS window, and it worked.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum