12 April 2010

Run Exe From A CRM Button

Right, here's a nice easy one to ease me into this blogging lark.

I was recently asked how you'd go about firing an EXE from a CRM button, now this isn't the best thing to be doing but here's how to do it.

Note: The exe path must be visible from the client machine.

Assuming that you want the button to appear on the entity form add the following to the isv.config:

<Button Icon="/_imgs/ico_18_debug.gif" JavaScript="fireExe();">

Now you need to add the following to the OnLoad event of the entity that displays the button:

fireExe = function()
var oShell = new ActiveXObject("WScript.Shell");
//Note: all back-slashes (\) must be doubled up (Single \ is a control character in JavaScript)
var prog = "c:\\WINDOWS\\System32\\notepad.exe";
oShell.run ('"'+prog+'"',1);
The above example will fire NotePad whenever the user clicks the button.

Note: Internet Explorer security settings will probably need to be changed for the Internet Zone that CRM is running under to allow ActiveX code to execute.

No comments:

Post a Comment