I need to know how to pass information from a command to a variable in visual basic. For example:
From a dos window if you type dsquery user -name <username>
You will get the result on the screen. If you type
dsquery user -name <username> >c:file.txt
the output will go to the file listed.
I am trying to write a program that uses the dsquery user result to then execute a dsmove command. What I have is this (but it does not work ...nothing happens)
' build the dsquery command with output to a file and shell it
q$ = "dsquery.exe user -name " + Text1.Text + " >c:query.txt"
Shell (q$) ' (this shel does nothing and the file is not created)
Open "c:\query.txt" For Input As #1 '(error file does not exist.)
Input #1, c$
c$ = Chr$(34) + c$ + Chr$(34)
' finds the first "," in the string
For x = 1 To Len(c$)
If Mid$(c$, x, 1) = "," Then
If z = 0 Then z = x
' simply takes out the ou that I want to move out of
cc$ = Chr$(34) + Right$(c$, Len(c$) - z)
cc$ = Left$(cc$, 8) + Right$(cc$, 29) + Chr$(34)
' build the dsmove command and shell it
q$ = "dsmove " + c$ + "-newparent " + cc$
a = Shell(q$) ' this does not work even w/ information manually added to a query.txt file
My query result should look like this in the query.txt file...
the dsmove command should look like this:
C:\>dsmove "CN=14218,ou=2009,ou=no-internet,ou=students,dc=mcs,dc=local" -newparent "ou=2009,ou=students,dc=mcs,dc=local"
Any help would be GREATLY APPRECIATED! I have 5000+ students that started school 2 days ago and are strting to bring back computer use forms so they can have internet acces. I have a mess on my hands at the moment and am looking for a way to get them access quickly.
The reason for the sdquery is so I can find out what OU the student is in ie 2009 (freshman) 2008 (sophmore) etc
Thank you in advance for any help you can give me.