Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

320
Vistas
I have recently created a GUI using a .hta file I want to run a powershell script I wrote. I can't correct this error

I get this error: Error message I receive

I can not find what is actually the problem from my limited knowledge everything looks correct

Here is the code I am using:

<html>
<head>
    <title>Application Executer</title>
    <HTA:APPLICATION ID="oMyApp" 
        APPLICATIONNAME="Application Executer" 
        BORDER="yes"
        CAPTION="no"
        SHOWINTASKBAR="yes"
        SINGLEINSTANCE="yes"
        SYSMENU="yes"
        SCROLL="yes"
        WINDOWSTATE="normal">
    <script type="text/javascript" language="javascript">
        function RunFile() {
        WshShell = new ActiveXObject("WScript.Shell");
        WshShell.Run("C:Users\User\OneDrive\Desktop\Apps\Clean_Teams.ps1", 1, false);
        }
    </script>
</head>
<body>
<br>
<br>
<center>
<input type="button" value="Clean Teams" onclick="RunFile();"/>
<br>
<br>
<input type="button" value="Clean Chrome" onclick="RunFile();"/>
<br>
<br>
<input type="button" value="Clean Edge" onclick="RunFile();"/>
</center>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As mentioned in the comments, you need to run powershell.exe with the appropriate parameters. Below is an example HTA for launching PowerShell scripts that demonstrates one way to set up the correct command line. Also note that X-UA-Compatible is set to IE=9. Without any declaration, the HTA will default to IE=5 mode.

<!DOCTYPE html>
<html>
<head>
<title>Script Selector</title>
<meta charset="UTF-8" http-equiv="X-UA-Compatible" content="IE=9">
<hta:application
  id=oHTA
  icon=Powershell.exe
>
<script>
Visible=1;
NoWait = false;
w = 640;
h = 480;
oWSH = new ActiveXObject("WScript.shell");
window.resizeTo(w, h);
window.moveTo((screen.availWidth - w)/2, (screen.availHeight - h)/2);

function RunScript(ScriptName) {
  if (db.checked) { x = "-NoExit"} else {x = ""}
  CmdLine = 'Powershell.exe ' + x + ' -ExecutionPolicy Bypass -File "' + ScriptName + '"';
  oWSH.Run(CmdLine,Visible,NoWait);
}

</script>
<style>
body  {background-color:LemonChiffon; font-family:Segoe UI; font-size:11pt}
br {font-size: 16pt} 
</style>
</head>
<body>
<input id=db type=checkbox>Debug (check to keep PowerShell console open)<br>
<input id=b1 type=button value="PowerShell Script 1.ps1" onclick=RunScript(b1.value)><br>
<input id=b2 type=button value="PowerShell Script 2.ps1" onclick=RunScript(b2.value)><br>
<input id=b3 type=button value="PowerShell Script 3.ps1" onclick=RunScript(b3.value)><br>
</body>
</html>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda