Service for XP that auto shuts down

  • Thread starter Thread starter Adrian
  • Start date Start date
A

Adrian

Hi
is this possible in VB.Net ?

How should I go about it?

The Idea is the service will run at a given time and shutdown the PC no
matter what state it has been left in!

Any pointers would be helpful not written much and have never written a
service :(

OS XP

thanks
 
Hi,

You can do this using a timer, the win32 API and windows service from the VS
IDE. Creating a windows service is relatively easy. You need to add a
windows service from your project ( >Add New Item >Windows Service). Switch
to code view and you'll see a couple of subs for executing code on start and
stopping of the service. You will also need to add the installer classes
which can be done back in design view of the service. Notice at the bottom
of the properties window a hyperlink for installer. Go from there.

As for the API, see
http://blogs.msdn.com/brad_mccabe/archive/2005/03/02/383542.aspx

Good luck and let us know how you get on.

Rgds, Phil
 
Thanks Phil, this is all very useful and gives me what I asked for.

Having slept on it I can see how it could easily be overcome by a user i.e.
just reset the internal clock! I was thinking if I have a thread that checks
the time every couple of minutes to see if its time to shutdown maybe I need
to get the time from the internet. or is there a better way to plug this
hole?

thanks

Adrian
 
I doesn't matter what holes you try and plug here, a user who really want's
to circumvent your intent is going to be able to do so.

One hole would be the user stopping the service then settting its startup
mode to manual or disabled. That will really do the trick.

So will the user uninstalling the service.

I think the user changing the clock would be the least of your worries.

If the user(s) shouldn't have permissions for changing settings on services
then maybe you should consider revoking their permissions for changing the
clock.

In my view, any user who changes the clock without having a justifiable
reason for doing so should be hung drawn and quartered. The only reason for
doing so is to do something that they shouldn't.
 
OK I see there could be a number of holes :( but it is a step in the right
direction!

I'm just trying to in stall and test the service but I want it to run a
local system but installutil service1.exe asks for a user name and PW, how
do I tell it to install as Local system?
 
OK just found out how to change it!

Adrian said:
OK I see there could be a number of holes :( but it is a step in the right
direction!

I'm just trying to in stall and test the service but I want it to run a
local system but installutil service1.exe asks for a user name and PW, how
do I tell it to install as Local system?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top