Windows Service + Powercfg.exe

D

Daniel

Hi,

I have created a VS Windows Services project to call powercfg.exe
every 2mins (in a timerdelegate). In On Start event of the service I
have set the process file name to powercfg.exe and have set argument
as "/create "my power scheme" and started the process. In the delegate
fucntion first the get the avaliable scheme and check for my existing
scheme ("my power scheme"), if its there I set other power settings
like monitor timeout, disk timeout etc,. Here the catch is when the
service is started for the first time the On Start event does not
create a power scheme. I tried creating a power scheme in a windows
application and it created, but not in a windows service. Is there
anything that I am missing?

Thanks.
 
L

Leon Mayne

Daniel said:
I have created a VS Windows Services project to call powercfg.exe
every 2mins (in a timerdelegate). In On Start event of the service I
have set the process file name to powercfg.exe and have set argument
as "/create "my power scheme" and started the process. In the delegate
fucntion first the get the avaliable scheme and check for my existing
scheme ("my power scheme"), if its there I set other power settings
like monitor timeout, disk timeout etc,. Here the catch is when the
service is started for the first time the On Start event does not
create a power scheme. I tried creating a power scheme in a windows
application and it created, but not in a windows service. Is there
anything that I am missing?

I know this doesn't relate directly to your question, but it may help. It
sounds like you are just creating a scheduled task rather than a service. I
personally would consider changing the app to be a console application and
call it using the scheduled task manager. For more info:
http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx
 

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

Top