ACTIVEXOBJECT in javascript FAILS!!! Calling a custom file from a custom directory on a machine doesnt do anything.

Hi,

I am trying to create a button which will open a custom file. To do so i have to use activexobject but it doesnt work in sage crm. Is it possible to use it in Sage?

Any suggestions are welcome.

Thank you.

the code:

<script language="javascript" type="text/javascript">
function runApp()
{
var shell = new ActiveXObject('WScript.shell');
shell.run('C:/Windows/notepad.exe');
}
</script>

<!--[if gte IE 8]>
<p>You're using a recent version of Internet Explorer.</p>
<button onclick='runApp()'>File</button>
<![endif]-->

<!--[if lt IE 7]>
<p>Hm. You should upgrade your copy of Internet Explorer.</p>
<button onclick="runApp()">File</button>
<![endif]-->

<![if !IE]>
<p>You're not using Internet Explorer.</p>
<![endif]>

<button onclick='runApp()'>File</button>

Additionally i also tried AddContent("<a href='C:/Windows/notepad.exe'>DEVS</a>"); in my custom DLL file but that didnt work either.

  • 0

    Hi,

    This is fairly straightforward, but you'll need to have control over the users' browser security. There's lots of reasons why this isn't generally done.

    The issue you're having there isn't to do with CRM as such - you're having problems with your path. Give this a go:

    function runApp() {

    var shell = new ActiveXObject('WScript.Shell');

    shell.run('"C:\\Windows\\System32\\notepad.exe"',1);

    }

    The above will only work in IE.

    To be a little more accurate, if the application's location (like in our Notepad example) is already in the system's %PATH% variable, you don't need to include the full path, just the program name.

    Rather than add a button using inline HTML, I'd suggest checking out button groups (Administration -> Advanced Customization -> Button Groups). You can add the code above to a Custom Content area, then add a new button group to a target screen. You can then add a button to the button group, with an action of "customurl" and a URL name of "javascript: x=runApp(); void(x);".

    In order for this to work, you'll need to set the "Initialize and script ActiveX controls not marked safe for scripting" option to Enable in IE's browser security. Doing this in the Internet zone would be a bad idea - you should add CRM to the Trusted Sites zone, then allow this option there.

    Alternatively, if you're using CRM v7.2, you should check out the addButton function in the new client-side API - it will save you from having to add the button group.

    ActiveX controls are IE-only, so you can't instantiate a new ActiveXObject in other browsers. Similar functionality used to be possible in Firefox, though support was removed for netscape.security.PrivilegeManager, so it's no longer possible.

    forums.mozillazine.org/viewtopic.php

    I don't believe that this was ever possible in Chrome.

    It may be possible to launch external applications usign either Firefox or Chrome by writing an extension, but that's a little beyond the scope of what we're lookign at here.

    Hope this helps,

    Rob