473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Service for XP that auto shuts down

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
Nov 21 '05 #1
5 1331
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/ar...02/383542.aspx

Good luck and let us know how you get on.

Rgds, Phil

"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
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

Nov 21 '05 #2
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

"Phil" <Ph**@nospam.com> wrote in message
news:dd**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
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/ar...02/383542.aspx

Good luck and let us know how you get on.

Rgds, Phil

"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
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


Nov 21 '05 #3
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.
"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
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

"Phil" <Ph**@nospam.com> wrote in message
news:dd**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
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/ar...02/383542.aspx

Good luck and let us know how you get on.

Rgds, Phil

"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
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



Nov 21 '05 #4
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?

"Stephany Young" <noone@localhost> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
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.
"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
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

"Phil" <Ph**@nospam.com> wrote in message
news:dd**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
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/ar...02/383542.aspx

Good luck and let us know how you get on.

Rgds, Phil

"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
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



Nov 21 '05 #5
OK just found out how to change it!

"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
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?

"Stephany Young" <noone@localhost> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
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.
"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
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

"Phil" <Ph**@nospam.com> wrote in message
news:dd**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
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/ar...02/383542.aspx

Good luck and let us know how you get on.

Rgds, Phil

"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dd**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
> 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
>
>



Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Peter Morton | last post by:
Hi.. we are running a webserver on IIS with a mysql backend. The mysql service shuts down extrememly frequently with an event log code 7031. Has anyone seen this before. Is it a configuration...
1
by: Peter Steele | last post by:
Okay, I assume I'm missing something obvious here. I have created a simple service in C# that on starting spawns a thread to do some processing. The service can be stopped with a "net stop" command...
4
by: UJ | last post by:
I have a program that will upgrade a service automatically. If the service already exists, it will delete the service and then reinstall it through code. To delete the service I'm using the...
2
by: Nick K. | last post by:
I'm trying to implement a FileSystemWatcher from a Windows Service. Everything works until I: Stop the Service Copy a file to the watched directory. Re-Start the Service. I would expect the...
7
by: Mark Rae | last post by:
Hi, I wrote a Windows service for a client a few months ago, and the client has now asked me to modify it so that it shuts itself down under certain circumstances e.g. a catastrophic failure of...
17
by: UJ | last post by:
Is there any way for a windows service to start a windows program ? I have a service that will need to restart a windows app if it needs to. TIA - Jeff.
3
by: SugarDaddy | last post by:
Here's my problem. I have an NT service (really a .NET service) running as local system. I have a .NET form running on the user account. The form and the service communicate via an IPC Channel...
2
by: Bill Davidson | last post by:
All: I have a Win32 service that takes about 30 seconds to shutdown (give or take a few seconds). I shut the service down via the 'Services' console on Windows Server 2003. When the service...
6
by: DM | last post by:
Hi All, I have written a server program which distributes real-time data to our customers and is also used by our customers to redistribute this data over their internal networks. The program is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.