Solved

After an idle period, shutdown a windows machine as NT service.

Posted on 2003-11-24
6
237 Views
Last Modified: 2010-04-05
Hi! I´m trying to make an application that can do shutdown a machine running windows 2000 or xp, after a certain idle period of time. But i´de like that the application running as NT Service. The goal is running without having to enter on session time. Can it be possible? And how?
Thanks All
0
Comment
Question by:frizze
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
snehanshu earned 63 total points
ID: 9815968
frizze,
  I am working on a utility that monitoris the Idle time of the PC. The way I am doing it is to hook to keyboard and mouse events to find out how long the system was idle (using a service). I check it periodically (using a timer) and save the idle time.
  If that helps, read on...
  I have asked a few questions at EE for doing that and you could have a look at those. There are two ways you could do it:
1) Using Journal hooks
2) Using individual Keyboard/mouse hooks
  When I asked here, I was recommended that for longer periods of time, non-journal hooks are better. But perhaps journal hooks are simple. So, you could decide on what you want.

Links:
  My journal hook service code is posted in this Q:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20794138.html

This is where I got the code for a DLL that creates Kbd hooks (non-journal):
http://www.swissdelphicenter.ch/torry/showcode.php?id=1722

This is for using the DLL described above from the service:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20750612.html

And this is the debate of what to use journal or other hook:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20750833.html

  I am asking you to chase a lot of links, but doing that gave me a better understanding of what I wanted. hope it works the same way for you too.
  Cheers,
...Snehanshu
0
 
LVL 7

Assisted Solution

by:sftweng
sftweng earned 62 total points
ID: 9832770
An easy way to detect that a machine is idle is described in:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20810017.html

Do you need assistance with running as a service and forcing shutdown?
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9849095
frizze,
  I have posted some code at
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20810017.html
  It shows how you could use a timer and Journal hook to perform some action on inactivity.
  The code is not for a service, but you can easily make a service out of it. Do let me know if you need any help with converting the code there into a service.
  Cheers!
...Shu
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9849110
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question