0

Executing a command with command line parameters (on Windows 8.1 64bit) works fine

test.pbrt --ncores 1

or

test.pbrt [--ncores 1]

Executing a command and writing the output to a text file (on Windows 8.1 64bit) works fine

test.pbrt > test.txt

How can you combine both of them (without generating a separate bat file)? The following seems to ignore the command line argument and even stops outputting to the command line (only outputs to the text file).

test.pbrt --ncores 1 > test.txt

Edit: .pbrt is an ascii text file, the default program for opening those files is an executable file I created

3
  • Try "test.pbrt --ncores 1" >test.txt Commented Feb 9, 2015 at 10:30
  • @MarioWerner output: '"test.pbrt --ncores 1"' is not recognized as an internal or external command, operable program or batch file. Commented Feb 9, 2015 at 10:31
  • Sorry, test.pbrt "--ncores 1" >test.txt should work. If not, what kind of file is "test.pbrt"? Commented Feb 9, 2015 at 10:34

1 Answer 1

2

The ">" directs standard output to a file. So if command stops outputing to console is perfectly OK. As about ignoring the parameters - it can be affected by script (what script is that - You didnn't specified)

Sign up to request clarification or add additional context in comments.

12 Comments

@Matthias what if you use the full program name / path? "C:\Path\To Your \Program.exe" test.pbrt --ncores 1 >test.txt ?
@Matthias, probably you used Explorer to create the association, which doesn't set the association in the HKLM registry hive, but instead stores the association in its own key, and it typically doesn't set it up right to handle command-line arguments. From an elevated command prompt, create and associate the file type, e.g. ftype pbrtfile="Path\To\Program.exe" "%1" %* and then assoc .pbrt=pbrtfile. You'll probably need to select the new pbrtfile filetype association in Explorer as well.
@Mathias, you need to use an elevated command prompt (i.e. run as administrator) to set the registry key.
@Matthias, here's a bit of background: Windows starts a new process via CreateProcess, but that requires a PE executable (typically .exe) or .bat/.cmd script. Executing other file types is handled by the shell32 function ShellExecuteEx, which calls CreateProcess with the associated open or runas (UAC) command found in the registry. The associations are defined in several places, for both the system and the current user. But the built-in ftype and assoc commands in the command prompt only work with keys set for the system (local machine) under HKLM\Software\Classes.
@Matthias, "%1" is the path to the file, in quotes in case it contains spaces. %* is the rest of the command line arguments.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.