1

I wrote small application in C# to control time my kido spent playing on PC.

Now I'm looking way to run this app as admin when kid logs in to his profile. App displays some warnings on screen and stores some stats in file. Thus it cant be run hidden / in the background (need to display on screen msgs) or be run with standard user privileges (logs can be removed...)

Spend hours trying to make this working via windows task scheduler but I coudnt make this app visible...

Any kind of tip will be very appreciated !

PS If running GUI admin apps on other user's desktop is not possible - maybe someone can advise where/how I can store log file so it want be easily accessible by (smart) kido :)

1 Answer 1

2

The correct way to do this is have the app run as a service or as another user, and then send windows to the user's (kid's) desktop. See the MSDN page on interactive services; while services are no longer allowed to run truly interactively, they can still indirectly interact with users, including users running under different accounts. The WTSSendMessage function can be used to show a message box on a currently logged-in session, or your process can use CreateProcessAsUser (if it has access) to create a process in the user's session that can be interacted with (while the parent process can still create log files that can't be deleted by the user, etc.).

EDIT: A process doesn't have to be running as a service to use those functions. They are useful to services, but also to any other process that runs (non-interactively) as another user.

EDIT 2: As for log files, these can (and should) be set up with Append-only permissions for the logging process. That way, even if the program is running with the kid's permissions, it can only append to the file (not delete, overwrite, truncate, etc.). You can open a file requesting only append access.

Of course, that doesn't avoid the kid just terminating the process. There's no way to prevent that without running it as another account, although a watchdog process (running, potentially, as another user) could try restarting it immediately on demand.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .