Link to home
Start Free TrialLog in
Avatar of pulupul
pulupul

asked on

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:

<html>
<head>
<script language=VBScript>

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

</script>
</head>
<body>
<input type="button" value="notepad" onclick=execute("notepad")>
</body>
</html>

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.
ASKER CERTIFIED SOLUTION
Avatar of nonubik
nonubik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nonubik
nonubik

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.
Avatar of pulupul

ASKER

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.
Avatar of pulupul

ASKER

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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pulupul

ASKER

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.