Execute another program through VB and save output

Hello. I have a problem and since i haven't used VB for a while i can't think of a way to do it.

I have a file in c:\temp which is called test.exe and is a command line program that is run like that:
test.exe -ip 10.0.0.0 -who - me
and shows some output info about that ip, etc..
BUT i have to do test.exe -ip 10.0.0.0 -who - me >temp.txt in order to save the output in a temp.txt file (that is what i want and not an visual output)
what i want to do is to make a VB (exe) file which will run every 10 minutes (i have managed to do that) and will execute the above thing (the one with the >temp.txt) and save the output of the test.exe in a file..
I am using VB6 and i can't think of how..
thanks in advance
mernionAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PePiCommented:

dim retVal as Double

retVal = Shell("C:\temp\test.exe -ip 10.0.0.0 -who - me > temp.txt", vbHide)


0
mernionAuthor Commented:
I have done that but it won't work.. it launces the test.exe but it doesn't create the temp.txt file.. I used vbmaximizedfocus in order to see that the program is launched and it is.. why is it not creating the temp.txt file thought?
0
vinnyd79Commented:
try using ChDir first

ChDrive "C:\"
ChDir "C:\Temp"
retVal = Shell("C:\temp\test.exe -ip 10.0.0.0 -who - me > temp.txt", vbHide)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

PePiCommented:
try creating a batch file and then launch the batch file like

Shell Environ("COMSPEC") & " /C C:\Temp\test.bat"

batch file should contain:

@echo off
cd c:\temp
test.exe -ip 10.0.0.0 -who - me > temp.txt
0
PePiCommented:
or you can try this:

Shell "cmd /C /A c:\temp\test.exe -ip 10.0.0.0 -who -me > c:\temp\temp.txt"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mernionAuthor Commented:
none of this works.. have you tried them b4 telling me or have you found them on the net? if they are working for you, then something is wrong with my VB. Just for the case, the one with the bat file: it runs the bat, but no temp.txt is created. If i run the bat by double clicking or from start>run it works perfectly!
Any other solutions?
0
Dudge669Commented:
mernion - Did you try putting the full pathspec on the output redirection?  If you just do ... -me > temp.txt it will show up in the vb app's current default folder.  Make sure you put the whole path that you expect the output to be in.

  instead of
Shell("C:\temp\test.exe -ip 10.0.0.0 -who - me > temp.txt", vbHide)
  do...
Shell("C:\temp\test.exe -ip 10.0.0.0 -who - me > C:\TEMP\temp.txt", vbHide)
0
mernionAuthor Commented:
Even though it didn't work, i will accept PePi's answer because is the closest to which i finally found to work which is this:

x = Shell("cmd.exe /c test.exe -ip 10.0.0.0 > c:\text.txt", 1)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.