Hey all, this would be my first time posting here. And I would generally not ask, but I have been struggling with this for two days now and I would sincerely appreciate any help that I know you coding-gurus could provide.

I am still a noob, but I try not to be. Up until now I had been fine running Google searches. I run Visual Basic 2010 in Visual Studio 2010. And my goal is the following:

I need to have a GUI made with Visual Basic that, on a button click: opens up a command prompt, runs dsquery, and then collects the resulting text from dsquery as a variable or an array. I thought this would be easy, and indeed, I was instantly able to find the shell("") command. The shell("") command works perfectly if I use the following code:

Shell("cmd /c dsquery * -scope subtree -attr ""cn"" -filter ""(&(objectclass=computer) (objectcategory=computer))"" -limit 0 >""H:\Desktop\ComputerOutput\AllWsg.txt""")

This works perfectly, and from here, I can easily do what I want by using streamreaders and streamwriters to manipulate text documents.

My question, in so many words, is this:

How would I go about porting the result from the shell("") command to a VB variable, without ever having a text document? Is this even possible?

I googled, and found plenty of examples of redirect.standardinput and redirect.standardoutput. However, no matter what syntax or combination I tried: when I looked at my resulting variable in a messagebox, it would be blank. Indeed, it seemed like when I would use redirect.standardinput, the command prompt would flash in and out of existance, completely ignoring my read / write commands.

Is there any way to either:
A) Make the shell("") command port to a variable
or
B) Use some other set of commands to do that?
or
C) Explain why redirect.standardinput may fail like that

Thank you all in advance, any help would be great!