I've been asked to see if we can create a sidebar link to an executable and start a program to run that has been installed on a user's local hard drive. Can that be done and what would the syntax look like?
Prior to this, I've only seen links to files in folders saved in an org that because of the mime type would cause WORD or Excel to open. Would we perhaps need to associate the program with a mime type or local path on their machine, and then have the link go to a local folder instead? Also, might this possibly need to be scripted in order to make it work if there is no universal mime type (I'm told there isn't)?
Edit #2
Have tried getting the IE JavaScript from the links Techtrekker posted to work: Run exe file using Java Script for IE and Running Applications Using nsILocalFile.launch() for Firefox, but seem to be having difficulties, so am posting the script I've been using to see if someone can spot the error of my ways.
I've attempted using "straight Javascript" in the Homepage Link to an executable with a path of C:/Program Files (x86)/UltraEdit/UEDIT32.EXE
Note: this program isn't important, it just happens to be a 32 bit program I'm using to demonstrate that this will work.
So, as straight script, here's what I put in for the link:
<script language="JavaScript" type="text/javascript">MyObject = new ActiveXObject( "WScript.Shell" )function RunExe(){MyObject.Run("file:///C:/Program%20Files%28x86%29/UltraEdit/UEDIT32.EXE");}</script><link onclick="RunExe()">UltraEdit</link>
Did I perhaps also need to escape the backslashes in the path?
I've also tried creating a custom link page using the code below through adding it as a Home page component and haven't been able to get it to work either. I have it's Behavior set as "Execute JavaScript" and the Content Source as "On Click JavaScript".
<script language="JavaScript" type="text/javascript">
MyObject = new ActiveXObject( "WScript.Shell" )
function RunExe()
{
MyObject.Run("file:///C:/Program%20Files%28x86%29/UltraEdit/UEDIT32.EXE") ;
}
</script>
<link onclick="RunExe()">UltraEdit</link>
So, could someone please tell me what I've overlooked or not implemented correctly from the link Techtrekker referenced? Its been a number of years since I've done any JavaScript and the 1st method above seemed to be the more logical and no different than what I've done in-line above.
Further, there seems to be a question of how to properly escape the paths from the Salesforce Orgs to the local executables on user machines when using JavaScript and which path format to use. A network path would use a \
notation while a local path would use a /
notation. Apex would escape characters with a \
while according to Javascripter.net, Javascript would escape the \
or encode it with a %5C
. In the case of the /
, it would escape it with another /
or encode it with a %2F
.
Needless to say, I'd be most appreciative of some clarification of how best to implement this as I've tried various combinations and don't seem to be able to get the IE version to work (am using IE8 and WinXP-64). Once I do, I'd like to get the Firefox version working for the client too.