Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!