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)?

migrated from stackoverflow.com May 11 '11 at 15:31

This question came from our site for professional and enthusiast programmers.


Try doing this:

%COMSPEC% /c "%ProgramFiles%\7-Zip\7z.exe" ...
  • Thanks; that worked (although I don't really know why). – Peter Mounce May 11 '11 at 22:46
  • @Peter: TeamCity is likely actually executing it with the argv [... "-y", ">", "NUL"] or otherwise executing the file "C:\Program Files\7-Zip\7z.exe x foo.7z...". – Hello71 May 12 '11 at 0:02
  • Ah, yes; that would make sense. It has one textbox to take the exe, and one to take the arguments. – Peter Mounce May 12 '11 at 0:08

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.

  • 1
    It works fine for me from a console too; it doesn't work fine when it's the TeamCity build-agent (running as a service) that is executing the command headlessly. It's the TeamCity involvement that made this a stackoverflow.com question, which was why I asked there; unfortunately it got moved and I don't know how to appeal to a moderator. – Peter Mounce May 11 '11 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.