I have following javascript code to run notepade.exe:
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
function executeCommands()
{
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun ="C:\WINDOWS\notepad.exe";
oShell.ShellExecute(commandtoRun,"","", "open", "1");
}
</SCRIPT>
The problem is that, when i run the script then it give error..."Permission denied."
Can anybody help me on this matter?
It's necessary to have two settings turned on.
Enable unsigned ActiveX controls for the current zone
Tools > Internet Options > Security > Custom level...
Enable "ActiveX Controls and plug-ins" > "Initialize and script ActiveX controls not marked as safe for scripting"
Allow Active Content to run files
Tools > Internet Options > Advanced > Security
Enable "Allow Active Content to run in files on My Computer"
** Make sure to close all your IE browser windows.
You may experience a "Permission denied" error, which means that the browser will not let script execute outside the "sandbox". Try solving the issue by changing a security setting in the browser:
Internet Options, Advanced, Security:
"Allow Active Content to run in files on My Computer"
The above is for IE, but most browsers have similar options.
Okay, weirdly, I had this issue when running a .html file I'd created on my desktop into IE... but when I moved the file onto a WAMPServer it worked okay; Not quite sure why that should solve the problem, but maybe that'll help someone!?
Related
I have a situtaion where i need the command prompt to open on the click of a button. for this i started of by usign jsp.
var wsh = new ActiveXObject('WScript.Shell');
command = "cmd /k D:\ & cd testTrial & trial.bat & echo DONE!"
wsh.Run(command);
The problem is that this wont run in firefox as ActiveXObject is a Microsoft propritory.
Is there a way i can check the browser and then run the above code keeping the current browser in mind.
This sounds like a security hole... I don't think you will be able to do that.
As I know for security reason other browsers does not allow to access local resources.
I am getting script error in loading some web sites.
Please help me how to prevent script error in C# WebBrowser.
This is my code:
try
{
webBrowser1.Navigate(textBox1.Text);
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
MessageBox.Show("Loaded");
}
catch(Exception)
{
MessageBox.Show("failed");
}
Write this in Your Code
webBrowser1.ScriptErrorsSuppressed = true;
To disable the script error pop up, you need to go to (in Internet Explorer) Tools->Internet Options, there go to the Advanced tab, and in Browsing select Disable Script Debugging (Other), but, the problem may be related to the fact that every site loaded in the WebBrowser control is rendered in IE7 compatibility mode, to solve this the only thing you can do is a registry hack like this: WebBrowser control to use IE9
change your registry to 2af8 which is IE 11 for devenv.exe
software/Microsoft/internet explorer/main/featurecontrol/feature_Browser_emulation
If your working with a GUI (like in Visual Studio) just go to the Webbrowser Properties and set "ScriptErrorsSuppressed" = true
It is easy to see how this error has been eliminated. But Visual Studio uses Internet Explorer and another Web Browser coding is hard. If you look at the versions, the last Visual Studio one uses IE 11 for WebBrowser tool.
The C++ GUI is recommended for one of each encoding:
https://msdn.microsoft.com/en-us/library/60k1461a.aspx
I am trying to run shell command to open notepad from JavaScript. This is how my code looks like:
<script type="text/javascript">
function runNotepad() {
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\\WINDOWS\\Notepad.exe";
oShell.ShellExecute(commandtoRun, null, "", "open", "1");
}
</script>
When i try to run this, it throws me an error saying Microsoft JScript runtime error: Permission denied.
I also have set Allow active content to run in files on my computer in IE but still no luck.
Any idea what am i missing here?
Any idea what am i missing here?
No browser would allow JavaScript to arbitrarily start a process. This functionality is not available in Internet Explorer because of the security implications.
This will work if run from other Scripting Hosts, such as cscript, but not Internet Explorer.
You can't run or create native objects inside webpage javascript. The idea is that if someone could do that, then they could create a FileSystem object. Then, while you idly browse their webpage, they play havoc with your file system.
If you need to do this, and have the file saved on the host's machine, save it as an HTML app (*.hta).
I save this file as test.html and when I opened this file in IE, I am getting Information Bar for ActiveX Controls, Is there any way we can disable this thing using javascript code or jQuery code?
<html>
<body>
<h1>My First Web Page</h1>
<script type="text/javascript">
if(navigator.appName == "Microsoft Internet Explorer")
{
window.location = "http://www.google.com/"
}
else
{
window.location = "http://www.yahoo.com/"
}
</script>
</body>
</html>
And I just wanted to make sure, as I am running locally on my box so that is the reason it is showing ActiveX control Information bar? And Once I upload this file to a remote server and access it from there then this active x bar will not appear??
But is there any way programmatically to disable this information bar? Any suggestions will be appreciated.
Use Mark of the Web (MOTW). We can disable the ActiveX controls warning by putting following code before the opening html tag:
<!-- saved from url=(0014)about:internet -->
<html>
<body>
......
</body>
</html>
The above code is call “Mark of the Web (MOTW)”, this is a feature of Windows Internet Explorer that enhances security by enabling Internet Explorer to force Web pages to run in the security zone of the location the page was saved from
The Information Bar you're seeing is unrelated to ActiveX (even though it might say "ActiveX"). It's simply telling you that a IE isn't running scripts on a local file, a security precaution.
Yes, when accessed via HTTP, the warning won't appear.
There's no way to programmatic disable it because (1) your code isn't running in the first place; and (2) doing so would circumvent the security restriction that this is meant to be. Use the MOTW.
If you just want pages to work on your machine, go to Tools, Internet Options, Advanced, and check Allow active content to run in files on My Computer. I'd only enable this option while developing, however.
I am currently using javascript to enable changes to css on hover for certain items in my html page. In Firefox I never get an ActiveX message but in IE8 I get a message stating "To help protect your security, Internet Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer. Click here for options..." I'm assuming its because of the javascript I have:
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
The hover effects still work in IE8 without me clicking on the warning and allowing ActiveX.
My questions are:
1) Is there a way for me to change the javascript I have in place for the hover effects so the ActiveX warning doesn't pop up?
2) Is there code to disable the ActiveX warning since the website works fine in IE even with the warning?
Thank you
That's the default security restriction when you open it by local disk file system instead of by webserver. In other words, it won't occur when you change the security restrictions in the browser configuration or serve it by a (local) webserver like http://localhost/test.html
In Firefox I never get an ActiveX message
ActiveX is MSIE proprietary, you indeed won't ever see this on browsers other than MSIE.
You can try this if it work :
Add this to your ASPX code.
<!doctype html>
<!-- saved from url=(0023)http://www.contoso.com/ -->
It happens only when you work with local files, if it still bothers you, check this out: http://msdn.microsoft.com/en-us/library/ms537628(VS.85).aspx