Export (0) Print
Expand All
2 out of 3 rated this helpful - Rate this topic

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""")

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.