Situatie
Cum putem executa un batch file sau un executabil folosind Javascript si HTA
Pasul 1
Copiem urmatorul cod intr-un editor de text
<html>
<head>
<title>Ruleaza un exe sau batch file cu Javascript si HTA</title>
<HTA:APPLICATION
APPLICATIONNAME=”Ruleaza un exe sau batch file cu Javascript si HTA”
ID=”MyHTMLapplication”
VERSION=”1.0″/>
</head>
<script language=”Javascript”>
function RunMe(){
var shell = new ActiveXObject(“WScript.Shell”);
var path = ‘”file:///E:/Users/Desktop/hello.bat”‘;
shell.run(path,1,false);
}
</script>
<input style=”width: 170px; height:23px; color: white; background-color: #203040;
font-family:Book Antiqua;” type=”button” Value=”Execute Batch File” onClick=”RunMe();”
</html>
Pasul 2
Modificam calea programului pe care dorim sa il executam (var path)
Pasul 3
Salvam fisierul cu numele dorim si extensia .hta
Leave A Comment?