Disable security warnings in an ActiveX WebBrowser control

I'm using a WebBrowser ActiveX control with C++ (and MFC). I'm calling the control's methods through an IWebBrowser2 COM interface.
The point is: I want to be able to have links in the contained HTML code that launch applications. To achieve this, I have the following HTML + VBScript code, which works fine:

<script language=VBScript>

sub execute(what)
set objShell=CreateObject("Wscript.Shell")
end sub

<input type="button" value="notepad" onclick=execute("notepad")>

But I get a warning dialog bos telling me that executing that code could not be secure, and asking if I want to continue. I want to configure the WebBrowser control in a way that the warning is not showed.
Who is Participating?
nonubikConnect With a Mentor Commented:
For this you can just set some registry keys values for IE
They are to be found in
     HKCU\software\microsoft\windows\currentversion\internet settings\zones\
There you have like 5 zones, from minmum level to maximum. They are the settings from IE->Tools->Internet options -> Security tab -> Custom level
You'll just need to find out which one of them (as they are numbers like '1001') need to be reset.

In your case I suspect it's an option that has the radio button set to 'prompt'
Is 'Run ActiveX controls and plugins' set to 'prompt' ? Or is something about scripting?
If you cnat tell exactly what option has to be changed, maybe I can help more.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

pulupulAuthor Commented:
But that would change that setting for the whole system, which is a considerable security risk. I need to disable the warning dialog only in my instance of the WebBrowser control.
Of course. You'll just write a function inside your app that does the following:

retain the old value of that regkey
set it (yep, for the whole system) for your control
put the old value back after finishing.
pulupulAuthor Commented:
I can't do that, because I have no code that handles the event, everything happens "inside" the WebBrowser control. The other option would be to change the registry key in WebControl creation, and restore it in destruction, but this is not feasible since the control exists during long time periods, and the system would be exposed to attacks in that time.
meskiConnect With a Mentor Commented:
Are you implementing IObjectSafety inside your ActiveX object?  There's some info on it here.
pulupulAuthor Commented:
What is IObjectSafety and what is it for?, I have read the URL but I can't get to understand what is it about. I don't know much about ActiveX.
If Internet Explorer determines that your control supports IObjectSafety, it calls the IObjectSafety::SetInterfaceSafetyOptions method prior to loading your control in order to determine whether your control is safe for initialization.
A second way to mark your ActiveX as safe is using the Component Categories Manager, registering some keys. There's a whole example on that link.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.