UWP console app

Piotr 6 Reputation points

I want my UWP app to be really Universal. I mean, it should work as normal Windows app, but also with command line interface.

I know I can
(1) make execution alias, and access command line parameters:

(2) make command line app: https://learn.microsoft.com/en-us/windows/uwp/launch-resume/console-uwp

To add some command line support, I used method (1).
But I cannot (or, I don't know how) write to console from such app. I can only read command line arguments (and, e.g., send Bluetooth packet to my bulb to change color).

There is also (2), so I added RemoteSystem support for my main app, and make small console app to send commands from command line via RemoteSystem to my main app, and use Console.WriteLine to print output received from my main app via RemoteSystem.
But it seems that console app cannot use RemoteSystem (oAppSrvConn.OpenAsync() exception - but same code used in another UWP app works ok).

So, is there any possibility to have universal app written in UWP? I mean, same app for command line in/out, and for Windows UI?
Or, maybe, last implementation of idea of universal app was IBM OS/360? :)

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Sam of Simple Samples 5,516 Reputation points

    I think you need to develop a Class Library application and then two separate applications that use it, one for a console interface and another for a GUI interface. You do not state what language you are using; for C++ you might need to use a Windows Runtime Component instead of Class Library. This configuration is consistent with other types of applications.

    If you must develop one application that supports both types of UIs then you could develop a text-only interface in a GUI application but Standard I/O could not be supported.