troubleshooting Question

Need to convert VB Script code to VB.NET

Avatar of bpl5000
bpl5000 asked on
Visual Basic.NET
6 Comments1 Solution723 ViewsLast Modified:
I have been using vb scripts and now I want to start using VB.NET.  I have used VB6, but VB.NET is new to me.  Can someone help me convert this vb script program to vb.net?

strInput = InputBox("Enter Group Name:")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("members.txt", True)
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 9999
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT Name, ADSPath FROM 'LDAP://dc=bcsd,dc=local' WHERE objectCategory='group' " 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Set WshShell = WScript.CreateObject("WScript.Shell")

bFound = False

Do Until objRecordSet.EOF
	If Trim(LCase(strInput)) = Trim(LCase(objRecordSet.Fields("Name").Value)) Then
		bFound = True
		Set oGroup = GetObject(objRecordSet.Fields("ADSPath").Value)
		arrMemberOf = oGroup.GetEx("member")
		For Each member In arrMemberOf
			Set oUser = GetObject("LDAP://" & member)
			objFile.WriteLine oUser.cN
		Next
		Exit Do
	End If
	objRecordSet.MoveNext
Loop
If bFound Then
	objFile.Close
	Call WshShell.Run("%comspec% /c sort.exe members.txt /o members.txt",0)
	Call WshShell.Run("members.txt")
Else
	MsgBox "Group """ & strInput & """ not found"
End If
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros