0

I'm trying to build an application that would run on startup for all users, but non-admin users shouldn't be able to close it. I apologize if this has been answered, but I cannot find the answer even after googling it.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • What kind of application? It matters. If you want a kiosk application for example, you can use [Kiosk Mode](https://learn.microsoft.com/en-us/windows/configuration/kiosk-single-app) – Panagiotis Kanavos Jun 02 '20 at 14:20

2 Answers2

0

The easiest way would probably be to check if the current user is an Administrator in your program's OnClose() event and cancel the event if the result is false. Check here for more details on how to do that: Check if the current user is administrator

LordPupazz
  • 619
  • 3
  • 15
0

Sounds like it is a system level process, that is only marginally controlable by the Administrator. Controling System processes is one of the Admin tasks.

The two ways to start something with Windows are:

  • Make it a service. However do note that services operate under severe limitations, like not be able to create GUI themself. If you want to have any UI, you have to use a seperate process that talks with the service with IPC.
  • Have the Windows Task Sheduler start it on Windows Startup, using the Admin Account. The sheduler has replaced services in many cases, even for builtin processes like the automatic defragmentation.
Christopher
  • 9,634
  • 2
  • 17
  • 31