Redirect 7-Zip's command-line output to /dev/null on Windows when extracting a .7z file
I have a command such as "C:\Program Files\7-zip\7z.exe" x foo.7z -y
which will extract (with full paths) to the current directory.
What it does that I don't want, though, is to spool out the individual paths to stdout. This is information that I don't need.
However, on Windows, redirecting this to NUL (the equivalent of /dev/null
on Linux) a la "C:\Program Files\7-zip\7z.exe" x foo.7z -y > NUL
produces no unzip'd files, because 7-Zip seems to unzip to NUL instead of pushing the command text-output to NUL (which is what we want).
Actually, that command works from a Windows command shell (that is, it unzips the files as I want but without logging text to the console), but ir doesn't from TeamCity's agent execution within its command-line build-runner (that is, it unzips into NUL).
How do I get it to do the same thing within TeamCity (which is executing as a service)?
Try doing this:
%COMSPEC% /c "%ProgramFiles%\7-Zip\7z.exe" ...
7z.exe x foo.7z -y > NUL Works fine in my case. Are you sure the behavior is not caused by something else and you do not see the error message because of output redirection?
Also, you can redirect the output into a file instead of NUL and thus also exclude it from the output.