Jump to content

Special startup problem


Recommended Posts

Hay, I've been working on a project for about 1/2 a year now, and the original project design was to have my project be able to run the 'install' commands on their remote machines, easy enough, but the problem i've been having is i've found 40 ways to have a program be created as a service or in one way or another, run at login, but i havn't for the life of me figured out how to get a program, either as a service or as a program, run a bootup. I have to have it run at boot up because they need to be able to install at any time, not just when someone it logged in. I might end up having to change the project description to some how have something in the client, but i thought i'd toss the ball into this forums quite capable hands to see what you guys could come up with. Anyways, thanks for any help

~Dark

Link to comment
Share on other sites

  • Moderators

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I'm quite certain that (at least some) services run before a user logs in -- Kerio Personal Firewall for instance shows its splash screen before a user enters their credentials at the login screen.

Link to comment
Share on other sites

  • Moderators

Okay, I think I can help you out with this one. It has been a while since I accually did this, but I think I still remember. First you need to download a couple utilities from the Microsoft Resource Kit (Srvany.exe and Srvinstw.exe).

  • Like I said, obtain the files listed above and extract them into the same folder. I normally create a folder called c:\winnt\system32\Service Installation Kit. You will need to copy the Srvany.exe to the same directory on the remote computer also.
  • Run SrvInstw.exe
  • Check Install Service radio box, click Next
  • Check Remote Machine radio box, enter the computer name, click Next
  • Enter the name for your service, click Next
  • Click Browse and select srvany.exe (which should be in the same folder as SrvInstw.exe), then click Next
  • Click Service is its own Process radio box, click Next
  • Select what user account you want this service to run under. If this service is to have its UI, check the Allow Service to Interact with Desktop checkbox. Normally the services run under System Account
  • Select the startup option, click Next
  • Click Finish. But you are not finished just yet
  • Open RegEdit, click File-->Connect Remote Registry, Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
  • Locate the service you just created in the Services branch, right click on it, select New-->Key.
  • Name the new key Parameters
  • Right click on Parameters and select New-->String Value, name the new string Application
  • Double-click on Application and set it equal to the full path of your executable (e.g. \\Server\MyApp.exe)
  • Now either restart the computer or use a remote service utility to start your service and your program should run without a user having to logon.
I know it sound very complicated, but it really isn't. Just be very careful when creating the reg edits. I would suggest making a backup first. If you have any other questions feel free to ask.
Link to comment
Share on other sites

I found this entry while using Sysinternal's free System File Defragger (aka PageDefrag). I don't know if this will work if your app won't run as a service, but under the reg key:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager

the value named BootExecute runs before the system comes up completely. Programs run from here run early enough that the system files (registry files, etc.) can be defraged by the utility. This is where Scandisk runs from on startup and repairs any disk problems.

Also, check out the source code for Silent Runners.vbs. It's a script designed to report all registry entries where an app can run or imbed itself into the OS. Much of it won't be relevant to what you're looking for, but there are a LOT of places it scans that programs can run from.

Hope this helps.

Link to comment
Share on other sites

hay i wanted to give you an update cause you seemed to be foaming at the mouth with anticipation :P. i did what you said and i rebooted. i had it run a program that all it did was pop up a msg box. now i checked the box to have the ui but it didn't popup, HOWEVER, i did hear the computer beep when the program poped open the msg and when i logged in the msg box was sittting right there, before the window ui was even beginning to load. this will probably be enough because my program doesn't have user interface, so i'm going to whip together a quick tcp program and set it as a service and see what happens, thanks for the help, i will get back to you

~Dark

Edited by DarkNecromancer
Link to comment
Share on other sites

awsome, it works great. I tryed it like 3-4 times, rereading your post to finally get it right but this will be crazy to see how i'm going to program a whole new app now by next week when its taken me 1/2 a year to program 3 :P , i might ask for an extension because now i know that it works. You are a life saver, thanks so much :lmao:.

EDIT: hmm i was playing with it a bit and it works when the computer boots, stays on when the user logs in, but it shuts off when the user logs off. Any ideas to make it always stay up?? I am running it as system

~Dark

Edited by DarkNecromancer
Link to comment
Share on other sites

  • Moderators

This is why your program is closing when you logoff. I'm have no clue on how to fix it, maybe someone else can help you out with this one.

For WIN32 graphical applications: when the currently logged-in user is logging-off, all WIN32 top-level windows receive WM_QUERYENDSESSION and WM_ENDSESSION messages. Some WIN32 applications choose to terminate upon receipt of such messages. In order for your WIN32 application to survive logoff, it must not do that: instead, your windows procedure should call the default windows procedure on these messages.

For WIN32 Console (i.e. character-mode) applications: when the currently logged-in user is logging-off, all Console applications receive a CTRL_LOGOFF_EVENT event from the Console.

If your Console application has registered a Console event handler (via SetConsoleCtrlHandler), it must ignore CTRL_LOGOFF_EVENT in order to survive the logoff

Link to comment
Share on other sites

I use a great little service app in a commercial server environment that will allow many configuration options, including a program to run befor and after the service. http://firedaemon.com/. It is inexpensive and highly stable, and you can try it a shareware to see if it works.

HTH,

billmez

darn, i might have to take this to them and see what they want to do. anways thanks alot for your help big_daddy

~Dark

Link to comment
Share on other sites

oo, its late and am so tired. I took a look at that thing and i couldn't figure out if it was capable of remote install/administration. I'll also try and meet with the Director of IT to see if he has any ideas and bring up what i found here. I'll take another look at that when i'm not falling asleep at the keyboard, thanks

~Dark

Link to comment
Share on other sites

awsome, it works great. I tryed it like 3-4 times, rereading your post to finally get it right but this will be crazy to see how i'm going to program a whole new app now by next week when its taken me 1/2 a year to program 3 :P , i might ask for an extension because now i know that it works. You are a life saver, thanks so much :lmao:.

EDIT: hmm i was playing with it a bit and it works when the computer boots, stays on when the user logs in, but it shuts off when the user logs off. Any ideas to make it always stay up?? I am running it as system

~Dark

A long shot.. can you not use the function OnAutoItExit and use it to relaunch yourself, you may need to be slightly cunning in that you change the name of you app after a delay on boot, then use singleton so only one instance is running. the delay would hopefully allow some overlap during this log off session when your program is relaunched

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...