Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to run DOS program with output

Posted on 2006-06-30
7
Medium Priority
?
206 Views
Last Modified: 2010-04-30
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.
0
Comment
Question by:newsquest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:justchat_1
ID: 17021558
Use shellexecute:
http://trixar.com/~makai/shellex.htm

and listuser should have a file extension...
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 150 total points
ID: 17022664
Or...

Call Shell(Environ$("ComSpec") & " /c c:\ListUser -d -t > C:\Results.txt", vbNormalFocus)

BFN,

fp.
0
 
LVL 1

Expert Comment

by:tguez
ID: 17039971
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
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17043801
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...
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17294947
Hi Dan,

Please consider a split of points between all contributing experts.

Thanks.

BFN,

fp.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question