Skip to content

Instantly share code, notes, and snippets.

@Depicus
Created February 18, 2015 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Depicus/85f3f1efcdba3aa3f8ed to your computer and use it in GitHub Desktop.
Save Depicus/85f3f1efcdba3aa3f8ed to your computer and use it in GitHub Desktop.
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