Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with code issues between VBScript and VB

Status
Not open for further replies.

MadMike1272

IS-IT--Management
May 11, 2007
1
US
I am trying to convert a .vbs script I have to pull the local admins of a server into a Server management Windows Application in VB. Everything is fine except VB does not except the Array statement in a filter like VBScript does. (It flags array as a type not an expression) Anybody have an idea for a replacement that will accomplish the same goal?

Here is the line the VB doesnt like:

oComputer.Filter = Array("group")

Here is the full code:

strGroup = inputbox( "Please enter a group name", "Input" )
txtOut = strGroup & "memberlist.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(txtOut,ForWriting)

Set oWshNet = CreateObject("WScript.Network")

Set oComputer = GetObject("WinNT://" & strComputer & ",computer")
oComputer.Filter = Array("group")

For Each oGroup In oComputer
If ucase(oGroup.Name) = ucase(strGroup) then
objFile.WriteLine "Members of group " & oGroup.Name & ":"
For Each oAccount in oGroup.Members
strAdmin = mid(oAccount.ADsPath,9)
objFile.WriteLine strAdmin
Next
End If
Next



Thanks,

Mike Titus
 
Seems to work fine here once I defined [tt]strComputer[/tt] and gave it a value.

I suggest you try using [tt]Option Explicit[/tt] and declaring all variables. This helps track down a lot of simple errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top