I want to run .hta file from within .html file w/o the browser asking to download it.It should run in an iframe in the html page in the browser. The code i am using is this-
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<iframe src="app.hta">
</body>
</html>
The problem is that the browser asks to download the hta file but it want that it should run automatically.
The hta file code is this-
<html>
<head>
<title>Application Executer</title>
<HTA:APPLICATION ID="oMyApp"
APPLICATIONNAME="Application Executer"
BORDER="no"
CAPTION="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
SCROLL="no"
WINDOWSTATE="normal">
<script type="text/javascript" language="javascript">
function RunFile() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("c:/app.exe", 1, false);
}
</script>
</head>
<body>
<input type="button" value="Run Notepad" onclick="RunFile();"/>
</body>
</html>
Actually you can't open a HTA within iframe
even if the main app was a HTA. HTAs have their own OS windows, just like a browser or any .exe has.
What you can do, is to put your script to a regular html file. Depending on the security settings of IE, it executes the code, or ask user to allow to execute, or throws an error.
Notice also, that ActiveX
s work only in Internet Explorer. And like Dark Falcon has said, allowing ActiveX
execution from web would be a huge security risk. So trying to do these kind of things at a public website is not recommended.
If this is an intranet app, you can change the main app to HTA. Then you can add Run Notepad
button (and the script) to the main app, or to an iframe
, which has application=yes
set. Also trusted sites (html) can run ActiveX
s without prompting or errors.