Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, I'm 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 doesn't 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....

qrt
Posted
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?
My website
Posted

This is an answer I got from our tech bods:

 

 

The executable needs to be a service to run before logon.

I'm 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 I'm not sure how good an idea this is (depends on the executable, I guess).

 

 

hope this helps

My website
  • *Experts*
Posted

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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
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 it's 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?
qrt
  • *Experts*
Posted

Creating a service isn't that hard. There's 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, it's probably better as a service.

 

Generally, services have NO visual interface. Since it's 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 - it's really a matter of should you have ANY interface at all. I'd guess probably not.

 

-Ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
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.
qrt
Posted
The trick with the scheduled task seems to work exactly as I want on my workstation (win2K), but it doesn't seem to work on the Windows 2000 Server the program should run on. Does anyone know about settings that can be influencing this???
qrt
Posted
The server the application should run on was never updated I guess. Found 9 critical updates from the microsoft website. Works fine now.
qrt
  • *Experts*
Posted

If you really want to add a UI, don't 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 you're 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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...