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>
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>
Share
Improve this question
asked May 24, 2013 at 16:23
sdnr1sdnr1
3073 gold badges5 silver badges11 bronze badges
1
-
Is your server configured to correctly provide the right MIME type for an
.hta
file? – Ian Commented May 24, 2013 at 16:26
2 Answers
Reset to default 3Actually 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 remended.
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.
HTAs cannot be run under the browser. They run under a special host process called mshta
. Allowing opening of an HTA in a browser frame would be asking for problems, as HTAs have much higher privileges than normal web pages.