【发布时间】:2013-12-16 22:21:19
【问题描述】:
我想通过 vbscript 添加一个管理单元,但在将管理单元添加到控制台时遇到问题。它将在 Windows 7 环境中运行。如果有人可以看看并指导我正确的方向,我将不胜感激。谢谢。
<code>
'Elevated privileges start
'Start of UAC workaround code
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If WScript.Arguments.length =0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", Chr(34) & _
WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
consoleName = "C:\Burnett.msc"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(consoleName) Then
Wscript.Echo "console already exists"
Else
On Error Resume Next
Set objMMC = CreateObject("MMC20.Application")
If err.Number <> 0 Then
Wscript.Echo "an error occurred. unable to create mmc console"
Wscript.Quit(0)
End If
objMMC.Show
Set objDoc = objMMC.Document
objDoc.snapins.add("Local Computer\Non-Administrators")
if err then
'Trap the error just after the statement where an error/exception can occur and handle it elegantly
msgbox("Snap-in Not found")
err.clear
end if
objDoc.ActiveView.StatusBarText = "Pane 1|Pane 2|Pane 3"
objMMC.UserControl = 1
objDoc.Name = consoleName
objDoc.Save()
End If
Set fso = Nothing
End If
</code>
【问题讨论】:
-
到目前为止你的代码有什么问题?你有错误吗?如果是,在哪一行,错误信息是什么?
-
objDoc.snapins.add("Local Computer\Non-Administrators") 无论我使用什么管理单元,如果我关闭错误陷阱,我都会收到 8000FFFF 错误。 screencast.com/t/fQW9lOhb2w
-
我可以补充一点,我可以加载组策略对象编辑器,但我想进一步配置该对象,以便我可以设置本地计算机\非管理员。有没有办法列出所有配置组策略对象的方法?我对这种编程有点不知所措,需要一些学习。