newsquest
asked on
How to run DOS program with output
I have a command line application that lists various attributes of Active Directory users. I can run the application from the command line and have the results output to a text file, but when trying via VB there is no output.
Here is the code -
Private Sub Command1_Click()
Shell("c:\ListUser -d -t > C:\Results.txt", vbNormalFocus)
MsgBox "Done"
End sub
The application runs but just no output. Any help would be greatly appreciated
The d switch represents the disabled users and the t switch formats the output into tab delimited. I want to avoid having to use any batch files and just run the app directly from VB.
Here is the code -
Private Sub Command1_Click()
Shell("c:\ListUser -d -t > C:\Results.txt", vbNormalFocus)
MsgBox "Done"
End sub
The application runs but just no output. Any help would be greatly appreciated
The d switch represents the disabled users and the t switch formats the output into tab delimited. I want to avoid having to use any batch files and just run the app directly from VB.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The problem is that the commnd "> txt.out" is a dos command line command. Then shell is not a command line. It just run programs. So I don't know if what the user suggested above wrote works.
But if that does not work, try type your command into *.bat file. Then use the shell command to run the *.bat file. This should work just fine. The only side effect that you will see a command window open and flash and close. So you might want to specific minimize option when you execute the shell command, so the user will not see a flashing screen.
Tomer
But if that does not work, try type your command into *.bat file. Then use the shell command to run the *.bat file. This should work just fine. The only side effect that you will see a command window open and flash and close. So you might want to specific minimize option when you execute the shell command, so the user will not see a flashing screen.
Tomer
The shell is running a program, the command interpreter, and passing his program as an argument...
The code specified above works perfectly, give it a try...
The code specified above works perfectly, give it a try...
Hi Dan,
Please consider a split of points between all contributing experts.
Thanks.
BFN,
fp.
Please consider a split of points between all contributing experts.
Thanks.
BFN,
fp.
http://trixar.com/~makai/shellex.htm
and listuser should have a file extension...