c# - Write to command line if application is executed from cmd -


i searched web , stackoverflow, didn't find anything. sorry if question exists.

if c# application called through cmd example:

c:\system32\myconsoleapplication -parmone -paramtwo ...

is there way write cmd (for example giving progressinformation?)

edit: cause use consoleapplication solution ist console.writeline doesnt worked me cause application requires adminrights (trough manifestfile) , called normal userrights. in case uac asks rights , opens new cmd application.

this depends on exe type - flag in pe-header (the "exe" shell):

  • if flagged windows app, doesn't console / output existing console - regardless of how started
  • if flagged console app, does console / output existing console - regardless of how started

it cannot both. want work windows exe normally, have compile windows exe, means no: won't write console normally. trying acquire access console windows exe tricky, , require p/invoke os.

if is flagged console exe, console.writeline work fine.