Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Moniker Strings in Visual Basic and VBScript

In Visual Basic or VBScript, objects can be created using the GetObject function combined with a moniker string. The following two examples show the difference between using a moniker string and not using a moniker string. The first example uses monikers as a concise alternative to the second example.


' First example
Set Service = GetObject("WinMgmts: _
    {impersonationLevel=impersonate}!Win32_Service=""ALERTER""")

' Second example
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer       
service.Security_.ImpersonationLevel _
    = wbemImpersonationLevelImpersonate  
Set objinstance = Service.Get("Win32_Service=""ALERTER""")


 

 

Show:
© 2015 Microsoft