Questions

Scripting MMC with VBscript

Tags: Windows
+
0 Votes

Scripting MMC with VBscript

daniel.rahenkamp
Hi,

I am a bit out of my depth here so I have some questions. At my site we do unattended installs and configuration of our machines. I would like to script the install of a mmc snap in but have come to an impasse. I have found some sample code but I cannot find documentation to take me further. I would like to add the Group Policy Object Editor which I can do. But I want to further configure it to the local policy/Non-administrators which is where I get suck.

Below is what I have so far any and all help will be welcome. Thanks in advance.

d
'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

'start code here

'################################################
' VARIABLE DECLARATIONS
'################################################
'Option Explicit
Dim objSCANode
Dim objMMC

'################################################
' EXECUTE 'Open Database...' MENU ITEM
'################################################
Set objMMC = CreateObject("MMC20.Application")

objMMC.Document.SnapIns.Add("Group Policy Object Editor")
objMMC.Show
Set objSCANode = objMMC.Document.ScopeNamespace.GetChild(objMMC.Document.RootNode)
objMMC.Document.ActiveView.Select objSCANode
objMMC.Document.ActiveView.SelectionContextMenu.Item(2).Execute


'################################################
' DEBUG LINES
'################################################
wscript.Echo "objMMC.Document.RootNode.Name: " objMMC.Document.RootNode.Name
wscript.Echo "objMMC.Document.ScopeNamespace.GetChild(objMMC.Document.RootNode): " objSCANode.Name ' "Group Policy Object Editor"
wscript.Echo "objMMC.Document.ActiveView.Memento (objSCANode.Name): " objMMC.Document.ActiveView.Memento
wscript.Echo "objMMC.Document.ActiveView.Selection.Item(1): " objMMC.Document.ActiveView.Selection.Item(1).Name
wscript.Echo "objMMC.Document.ActiveView.SelectionContextMenu.Item(2).DisplayName: " objMMC.Document.ActiveView.SelectionContextMenu.Item(2).DisplayName
wscript.Echo "objMMC.Document.ActiveView.SelectionContextMenu.Item(2).Path: " objMMC.Document.ActiveView.SelectionContextMenu.Item(2).Path

'end of code here

end if
'end or UAC code

Member Answers