Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command arguments and "Start without debugging"

Status
Not open for further replies.

BlayneM

Instructor
Jan 27, 2005
2
US
I've created a Win32 console project using Visual Studio .NET 2003; the app reads from the standard input stream (cin). I want to redirect input to the app from a text file named test.dat, which is located in the project directory.

I open the properties dialog for the project, and under "Configuration Properties/Debugging", I change the value of "Command Arguments" to
< $(ProjectDir)test.dat
I make this change for "All Configurations", and I close the project properties dialog.

When I run the app by selecting "Debug/Start" from the main menu of the IDE, it runs fine, reading and processing data from the file test.dat.

But, when I run the app by selecting "Debug/Start Without Debugging" from the main menu of the IDE, it waits for input from the keyboard rather than reading from the redirected file. A little more experimentation uncovered the fact that the app, in this case, is viewing the "Command Arguments":
< $(ProjectDir)test.dat
as two command line arguments to the app, rather than viewing them as an input redirection.

Does anyone know a workaround for this, short of passing a file name into the app so it can open the file, or running from a command prompt window?

Thanks for any help you can provide.
 
Command line stdin redirection (for test.exe, for example):
Code:
test <test.dat
You can set <test.dat as a program arg in Project|Settings|Debug (for Release or/and Debug configuration) to start a program with redirection from IDE.
 
Thanks for the suggestion, but in my original message, I tried to convey that I'd already tried this approach. The redirection in Project|Properties|Configuration Properties|Debugging works for "Start" (i.e., debug) runs, but not for "Start without Debug" runs.

Any other ideas?
 
> as two command line arguments to the app, rather than viewing them as an input redirection.
Which seems to suggest it's bypassing the shell completely

Try something like
Code:
cmd /c $(ProjectDir)test.exe < $(ProjectDir)test.dat

Another possibility is look in the Tools menu and click on the "Add tool...". Here you can add a menu option to run any program you like.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top