Starting an executable

Kurt

0
Joined
Feb 14, 2003
Messages
113
Location
Los Angeles
Hi, Im searching for a way to make an executable run when the computer boots. The project I made should probably have been a windows service, but hey... I made a normal executable (:-\)
Is there a way to start this executable from the system account before anyone logs in on the pc? The pc is running windows 2000 server. I tried with the autoexec.nt file under winnt\system - directory, but that doesnt seem to be the answer. Now I found some keys in the registry, so the executable starts for every one that logs in...... but not before anyone logs in, and the visual interface of the program is shown to the user that logs in, which should not be the case....
 
Might not be the answer but have you looked at the details for scheduled jobs as these run when the computer is on but no one is logged in?
 
This is an answer I got from our tech bods:

The executable needs to be a service to run before logon.
Im not a developer, so cannot give more detailed advice.
However I know there is a Windows 2000 resource kit utility "srvany.exe" that allows executables to be run as services, but Im not sure how good an idea this is (depends on the executable, I guess).

hope this helps
 
You can use the task scheduler. You go to C:\Windows\Tasks and click "Add Scheduled Task". You select the EXE (or BAT file or whatever you want) and pick the run time (When My Computer Starts). For that option you specify the userid/password for it to run as.

You could also create a service instead of the EXE but the above would work just as well for most cases.

-Ner
 
Windows service would be the best anyways since this application should continuously run and almost no user interface is required. Besides, I think to have read that its possible in .NET to use an object to connect to a service and provide some form of visual interface anyways... For now I will start using the scheduled task solution. Possibilities to convert to a windows service? Or is this very time consuming?
 
Creating a service isnt that hard. Theres a template for creating them, I believe that makes it pretty easy. If I remember right, you just hook to the three or four events (start, stop, etc.). If the program needs to continually run, its probably better as a service.

Generally, services have NO visual interface. Since its being started by a username that may not currently be logged on, how would you expect the currently logged on user to view anything? The same would be true for a scheduled task - its really a matter of should you have ANY interface at all. Id guess probably not.

-Ner
 
The service itself shouldnt include an interface, but one should definately be available as a separate executable or MMC plugin given the need for configuration.
 
Yes... no interface is necessary. But it might be nice if for example any user that logs in on the computer could see some statistics of the service and make some configurations when having the rights.
 
The trick with the scheduled task seems to work exactly as I want on my workstation (win2K), but it doesnt seem to work on the Windows 2000 Server the program should run on. Does anyone know about settings that can be influencing this???
 
The server the application should run on was never updated I guess. Found 9 critical updates from the microsoft website. Works fine now.
 
If you really want to add a UI, dont add it to the service. Instead, make it a separate EXE that modifies some configuration file/registry setting. You could have the EXE restart the service, if youre fancy.

As for statistics, you could use the performance counters for that (add your own category) or a custom solution such as logging to the Application Log or to a file or database.

-Ner
 
Back
Top