How to Run HTA as Administrator (Elevation)?


HTA (HTML Application) are designed to work on Windows only. The *.hta are interpreted by mshta.exe and *.vbs/*.js are interpreted by cscript.exe (Console Version) or wscript.exe (Windows Version).

The nice things about HTA are: the source code is HTML-style (in fact, it is HTML). You can have either VBScript or JScript (both supported by Internet Explorer) embedded in the HTML source code. If you rename the HTA as HTML and you would be able to view the GUI in the browser but most of the scripts will raise security warnings unless they are not dealing with Files, System-level stuffs.

With HTA, you can easily design an application with GUI and at the same time, capable of the system-level scripting stuffs which are lacked by HTML. So it has the good things for both *.vbs/*.js and *.html.

For example, in this post, you can see a very simple application is created, without any compiler, without any IDE, just notepad is enough.

By default, you will not be able to run as administrator (privileges elevated) the HTA. But if you save the following content as *.reg file and double click, which will update the settings in the windows registry, and you will have this option like other applications.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\htafile]
@="HTML Application"
[HKEY_CLASSES_ROOT\htafile\DefaultIcon]
@="C:\\WINDOWS\\system32\\mshta.exe,1"
[HKEY_CLASSES_ROOT\htafile\Shell]
[HKEY_CLASSES_ROOT\htafile\Shell\RunAs]
[HKEY_CLASSES_ROOT\htafile\Shell\RunAs\Command]
@="C:\\WINDOWS\\system32\\mshta.exe \"%1\" %*"

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
325 words
Last Post: C# Code to Convert .NET solution file to NDepend Project file on The Continuous Integration Server
Next Post: Simple HTA Template to Run Utility on File

The Permanent URL is: How to Run HTA as Administrator (Elevation)?

2 Comments

  1. Guest

Leave a Reply