This command generates an output file:
Update: See new command
Shell "cmd /c fc file1 file2 > result.txt"
i initially didn't use cmd /c
at the front of the command:
Shell "fc file1 file2 > result.txt"
That failed to generated the expected result.txt file. i don't know why. Including cmd /c
at the front of the command makes it work.
The subsequent Open
statement gets "Path/File access error"
iFile = FreeFile
Open "result.txt" For Input As iFile
Neither the file nor parent directory are open in Windows Explorer.
The following changes don't help (TaskKill
and AccessRead
):
vPID = Shell("cmd /c fc file1 file2 > result.txt", vbHide)
Shell "TaskKill /F /PID " & CStr(vPID), vbHide
iFile = FreeFile
Open "result.txt" For Input Access Read As iFile
The Open
statement works if it's run as a separate, subsequent process.
How to do the Open
in the same process?