使HTA文件以管理员身份运行(提升) [英] Make an HTA file run as admin (elevated)

查看:105
本文介绍了使HTA文件以管理员身份运行(提升)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在wsf,vbs和js文件中,您可以轻松查明它们是否提升运行,如果没有运行,则可以轻松地将它们制成.
我为此编写的代码是:

In wsf, vbs and js files you can easily find out if they run elevated and if not you can easily make them.
The code I've written for that is this:

EnsureElevatedPrivileges();
WScript.Echo("Running elevated now!");

function EnsureElevatedPrivileges() {
    if (!WScript.Arguments.Named.Exists("elevate")) {
        new ActiveXObject("Shell.Application").ShellExecute(WScript.FullName, "\"" + WScript.ScriptFullName + "\" /elevate", "", "runas", 1);
        WScript.Quit();
    }
}

但这在HTA文件中不起作用,因为全局WScript变量在那里不存在.
那么如何强制以管理员身份运行特定的HTA文件(本身)?

But this doesn't work in HTA files because the global WScript variable doesn't exist there.
So how can I force a specific HTA file run (itself) as admin?

推荐答案

您可以看一下:

这篇关于使HTA文件以管理员身份运行(提升)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆