Skip navigation

JSI Tip 10100. How can I determine if the WinNT provider returned a user, group, computer, etc.?


If you retrieve a script argument using the WinNT provider, you can use the Class property of the object to determine what type of object the argument was.

If your c:\util\test0.vbs script contains:

Dim objArguments, strDomainUser, Cls
Set objArguments = Wscript.Arguments
If WScript.Arguments.Count = 0 then Wscript.Quit
strDomainUser=objArguments(0)
Cls="NOT FOUND"
On Error Resume Next 
Set objUser = GetObject("WinNT://" & strDomainUser ) 
Cls=objUser.Class
Wscript.Echo 
" & strDomainUser &
" & Cls Wscript.Quit
Then see the following:
cscript //nologo c:\util\test0.vbs "JSIINC/Domain Admins"
"JSIINC/Domain Admins" Group

cscript //nologo c:\util\test0.vbs "JSIINC/Jerry"
"JSIINC/Jerry" User

cscript //nologo c:\util\test0.vbs "JSIINC/JSI001"
"JSIINC/JSI001" Computer

cscript //nologo c:\util\test0.vbs "JSIINC"
"JSIINC" Domain



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish