0
我想通過vbscript添加一個管理單元,並且我一直有問題想要添加到控制檯中。它將在Windows 7環境中運行。如果有人能夠看到並指引我朝着正確的方向,我將非常感激。謝謝。使用vbscript腳本編寫MMC
<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>
到目前爲止你的代碼有什麼問題?你有錯誤嗎?如果是,在哪一行以及錯誤信息是什麼? – Helen
objDoc.snapins.add(「本地計算機\非管理員」)無論我使用哪種管理單元,如果我關閉了錯誤陷阱,都會出現8000FFFF錯誤。 http://screencast.com/t/fQW9lOhb2w – roontoon
我可能會補充說我可以加載組策略對象編輯器,但我想進一步配置該對象,以便我可以讓本地計算機\非管理員設置。有沒有辦法列出配置組策略對象的所有方法?通過這種編程,我有點不深,需要一些教育。 – roontoon