Because you have /RU SYSTEM
. The system account is a special account and doesn't have a session with GUI like any account used for login. It's designed e.g. for unattended services that needs to run even when users aren't logged in. You can't log in as SYSTEM
.
Using Notepad as an example completely masks your true needs, but maybe (based on the comment) you are trying to build something that would actually need an architecture of an Interactive Service with a separate GUI client:
- Service starts without GUI during system startup.
- Hidden GUI client starts separately for every user session during login.
- The service communicates with the client, causing it to display the GUI whenever required.
Create a separate hidden GUI application and use the
CreateProcessAsUser function to run the application within the context
of the interactive user. Design the GUI application to communicate
with the service through some method of interprocess communication
(IPC), for example, named pipes. The service communicates with the GUI
application to tell it when to display the GUI. The application
communicates the results of the user interaction back to the service
so that the service can take the appropriate action. Note that IPC can
expose your service interfaces over the network unless you use an
appropriate access control list (ACL).
If this service runs on a multiuser system, add the application to the
following key so that it is run in each session:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
. If
the application uses named pipes for IPC, the server can distinguish
between multiple user processes by giving each pipe a unique name
based on the session ID.
Don't try to use Windows Task Scheduler for this purpose, but design your software better.