Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get the output of prog started with WinExec

Status
Not open for further replies.

firelex

Programmer
Jan 10, 2002
118
DE
Hello, all!

I have 2 directories: Temp1 and Temp2.
In each of them there are files. Many files.
I need to compare each file of directory Temp1 with the file having the same name in the directory Temp2. For that perpose I downloaded diff for windows. Works fine.
So I wanted to automize the whole process: I find a pair of files to compare and do following:
Code:
WinExec "C:Programms\Gnu\DiffUtils\bis\diff.exe" & " " & file1 & " " & file2 & " > D:\ProjectDiff\diffoutput.txt", 0

Here file1 and file2 are both files with full paths.

When I start this from command line it works all right - "D:\ProjectDiff\diffoutput.txt" is written. But if I start it from my programm I get an error from diff
diff: - unknown operand ">"

If I do not redirect the output of diff and call WinExec with the last parameter 1, then I see the whole output of diff in the black window the pops up after the diff-call.

Can someone tell me what's that??!!
 
In order to use I/O redirection you have to launch a shell.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
What is WinExec ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Code:
Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String, ByVal nCmdShow As Integer) As Integer
 
You may try something like this:
WinExec Environ("COMSPEC") & " /C C:programms\Gnu\DiffUtils\bis\diff.exe " & file1 & " " & file2 & " > D:\ProjectDiff\diffoutput.txt", 0

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top