Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A simple NT Services example required

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I'm in need of putting together a Windows NT service that will fire a procedure once a night at a preset time.
Can anyone give me some pointers as to how I can do this ?
A simple example that perhaps writes a line (indicating the run-time) to a text file would be ideal for me to hit the ground running with this.
Thanks in advance
Steve
 
OK - I've managed to get as far as creating myself a simple service to run on NT.
At present this includes a TTimer component and every 1 minute writes a line to a text file indicating the amount of drive space free.
The fact that this TTimer is running constantly - what impact will this have on the server. Will it be noticeable ?
I'm looking to extend the logic here such that I have a local variable (call it lcvToRun) which is initially set to False. As part of the TTimer event I intend to check the current time. If the time (is > 0:00) and (< 01:00) then I will set lcvToRun = True. If the time is (> 01:00) and (lcvToRun = True) then I reset lcvToRun = False and run the procedure coded to do the work as required on the server (potentially backing up a database).
Would anyone suggest this is the correct logic ?
How do I pass a parameter to this service (such that I can indicate a running time for the operation).
Any help would be appreciated.
Steve
 
I do not think that the timer will have a big impact on the sever. NT wes designed to handle multiple processes S. van Els
SAvanEls@cq-link.sr
 
Can anyone suggest how I might be able to only have the process run once a night at say 1:00am ?
Do I need to continually fire the TTimer component and determine the current time ?
Could anyone suggest a better approach than this ?
Thanks again.
Steve
 
Steve,

Do you have to do it yourself? I mean, here in my W2K box, I have a nice taskplanner, that will do nicely what you want, and then some. I can't recall from WinNT if it had that, but I can check if you like?

HTH
TonHu
 
Is there any reason why this needs to be a service? Why not just write an application and then have it run it as a Scheduled Task?
 
Is there any reason why you can't use an 'OnIdle' method to determine the current time.?
Mostly I agree with Mike. Run your backup with a scheduler.

Steve.
 
Hello All,

I looked, and then it came all back. Use the 'nice' scheduler 'AT' in WinNT (assuming you're using that) to do anything. You'll have to (auto)start the Scheduler service from the controlpanel, and make sure it starts after rebooting, but then you'll have a nice commandline tool 'AT' to get it going. Try AT /? to see all the options, and don't forget:
- Your NOT seeing any mapped drives, so map them if you need them.
- Use the /interactive switch for apps that run windowed (meaning: not in console-mode)

There is a tool called atnow that can (windows-)show you the currently scheduled tasks, but I don't know where I left it...
Normally, all is controled from the commandline.

On Win2K and WinXP: Checkout the scheduler/Taskplanner that you can see from the controlpanel.

Ok, the answer to the original question should be: ;-)
Look on for anything that's NT Service related, and don't forget Colion Wilson and his nice (NT-)site
HTH,
TonHu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top