Skip to content

Instantly share code, notes, and snippets.

@Depicus

Depicus/ad-fig12

Created Feb 18, 2015
Embed
What would you like to do?
Option Explicit
Dim TheRoot, TheDisplay, TheContext, TheMenu, TheLoop, TheNewMenu
set TheRoot = Getobject(LDAP://RootDSE)
set TheContext = GetObject("LDAP://" & "CN=409, CN=DisplaySpecifiers," & TheRoot.get("configurationNamingContext"))
Set TheDisplay = TheContext.GetObject("displaySpecifier","cn=user-Display")
TheLoop = 0
If Not IsEmpty(TheDisplay.adminContextMenu) Then TheMenu = TheDisplay.GetEx("adminContextMenu")
For TheLoop = LBound(TheMenu) to UBound(TheMenu)
If InStr(TheMenu(TheLoop),"&Default Printer") Then
MsgBox "Menu already exists ... exiting ..."
WScript.Quit
End If
Next TheLoop = TheLoop + 1
End If
TheNewMenu = CStr(TheLoop) & ",&Default Printer...,defaultPrinterAdmin.vbs"
TheDisplay.PutEx 3,"adminContextMenu" , Array(TheNewMenu)
TheDisplay.SetInfo
Set TheDisplay = Nothing
Set TheContext = Nothing
Set TheRoot = Nothing
MsgBox "Added Admin Context Menu item"
WScript.Quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment