How do I redirect output to a file with CreateProcess?

The code below creates a console-less process with stdout and stderr redirected to the specified file. #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { SECURITY_ATTRIBUTES sa; sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; HANDLE h = CreateFile(_T(“out.log”), FILE_APPEND_DATA, FILE_SHARE_WRITE | FILE_SHARE_READ, &sa, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); PROCESS_INFORMATION pi; STARTUPINFO si; BOOL ret = … Read more

UTF-8 output from PowerShell

Not an expert on encoding, but after reading these… http://blogs.msdn.com/b/powershell/archive/2006/12/11/outputencoding-to-the-rescue.aspx http://technet.microsoft.com/en-us/library/hh847796.aspx http://www.johndcook.com/blog/2008/08/25/powershell-output-redirection-unicode-or-ascii/ … it seems fairly clear that the $OutputEncoding variable only affects data piped to native applications. If sending to a file from withing PowerShell, the encoding can be controlled by the -encoding parameter on the out-file cmdlet e.g. write-output “hello” | out-file “enctest.txt” … Read more

What is the name for `

This is called process substitution: Process substitution is a form of redirection where the input or output of a process (some sequence of commands) appear as a temporary file. Also from Bash Reference Manual → 3.5.6 Process Substitution: Process substitution allows a process’s input or output to be referred to using a filename. It takes … Read more

Redirection with Runtime.getRuntime().exec() doesn’t work

The problem is, the redirection character (>) is a shell-based construct, not an executable. So unless you’re running this command through something like bash (which you’re not), it’s going to be interpreted as a literal character argument to your exiftool invocation. If you want to get this to work, you have two options: Get bash … Read more

tech