English 中文(简体)
检查证明书是否提高了许可
原标题:Check if the script has elevated permissions
  • 时间:2009-10-21 08:59:54
  •  标签:

我要检查一下我的录像带的操作背景是否允许我履行行政任务。

  • The solution should work on all Windows operating systems starting with Server 2003. (This rules out solutions which just check for membership in the Administrators group -- remember that there s UAC in Vista and Windows 7!)
  • The solution should be simple. A 50 LOC solution that checks the Windows group memberships (recursively, of course, since the user might be member of a groups which is member of a group ... which is member of the Administrators group) and then does some extra checks for Vista UAC is not simple.
  • The solution may be a bit dirty, so something along the lines of this solution would be ok.
  • It should not be too dirty. Writing a file to C:Windows or writing a registry key is too dirty in my opinion, since it modifies the system. (EDIT: Which might not work anyway: for example, when using VBScript in a HTA, UAC redirection kicks in.)

相关问题: (我在那里发现的所有答复都(a) 忽视了联安委的问题,(b) 存在错误,因为它们忽视了使用者获得行政许可的可能性,尽管他们不是署长集团的直接成员)

最佳回答

我知道,这一路面非常老,答案是明确的,但这是一种更简单的方法,一直为我工作。 用户S-1-5-19是地方非关税壁垒管理局,因此获得关键权。 它通过电梯运行。

Option Explicit 

msgbox isAdmin(), vbOkonly, "Am I an admin?"

Private Function IsAdmin()
    On Error Resume Next
    CreateObject("WScript.Shell").RegRead("HKEY_USERSS-1-5-19EnvironmentTEMP")
    if Err.number = 0 Then 
        IsAdmin = True
    else
        IsAdmin = False
    end if
    Err.Clear
    On Error goto 0
End Function
问题回答

这里最快的办法是提出文字档案或作为管理人的其他档案:

First create your VBS script of whatever you need to do. In my case it was a registry edit vbs to allow me to autoadmin logon then when the machine was restarted, another file was run to ensure that autoadmin logon was not enabled any longer.

After you have created your file, then you need to create a cmd prompt shortcut. Next Right click on the shortcut and change the propeties so that it will run as administrator.

Paste your file path like this: D:WINDOWSsystem32cmd.exe /c "D:DumpScriptsStartUp.vbs"

The C means it will close after completion If you want it to stay open then use K

希望有助于其他人。





相关问题
热门标签