views:

202

answers:

1

I may be SOL on this but I thought I would give throw it out for possible solutions.

I am writing a computer access control service to help me control my kids' computer use. Plan on open sourcing it when I have it working. It is written in VB.Net and needs to work on XP through 7.

I am running into all sorts of security and desktop access issues on Windows 7. The service needs to run as admin to execute the NetSh command to disable the network. But I cannot interact with the desktop from the service so I IPC to a UI to handle other stuff, but I still cannot detect from the service if the desktop is locked. Argghh!

I could get it all working from a hidden windows form app if I could just lick the one piece that needs admin permissions: disabling the network.

It does no good if a kid logs on and denies the popup asking if the program should run as administrator and he says no. Also windows 7 will not start a program set to run as admin using HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

Anyone know how to get this working? Or have an outside the box solution?

Thanks! Brad

+1  A: 

I wish I could provide some references, but I'm failing at my google-fu right now... but I'm pretty sure UAC doesn't apply to services. If you implement your program as a windows service application instead of a (hidden) windows forms application, and set it up to run for your kids' user accounts and not your own, that should work.

UPDATE

Found this on google, haven't played with it at all. Looks sound though... basically, CreateProcessAsUser to run the forms app from your service app that's running as administrator.

Tanzelax
It does apply if you are doing something that the UAC gets in the way of like executing the Netsh command that changes net settings. That only works when running under admin rights. I am running the service under admin privileges right now so that works. If I could run a forms app with admin privileges without the UAC popup, like I can do with a service, all of my problems go away.
Brad Mathews
@Brad, Yeah, I guess you were pretty much doing everything I was originally suggesting already. :p I did find another link that may solve your problem, updated my answer with it.
Tanzelax
@Tanzelax. Sweet! This solves my immediate problem of how to call Netsh without needing to be running as Admin. And it solves a problem I had given up on which was how to launch the UI from a service. I want my service to restart the UI if it gets closed and the UI to restart the service if it gets closed. I could only get the latter working. Don't want the kids getting around the access control by simply killing a process!
Brad Mathews
I want to add a warning to using this UAC subverting technique. Since you are running the new app under the SYSTEM account, you also inherit all of the limitations of this account. Namely, no network access. TANSTAAFL.
Brad Mathews