Results 1 to 15 of 15

Thread: Services are too tough

  1. #1

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Thumbs down Services are too tough

    Why is it so hard to make a service in NT based systems? It really shouldn't be that difficult.

    Sorry. Just had to say it.
    ~Peter


  2. #2
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    It is not that hard, really is pretty easy. Check out this attachment.
    Attached Files Attached Files
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  3. #3
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    Seem Too weired

    Hello.
    I was convinced to install Win2K. And am now confused on how secure it is.
    One friend mentioned servieces (how strange to run across this in the forum.) Could you explane to me what this attachement does?( seoptimizer2001 )

    Thanks seahag

  4. #4
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    This code allows you to install your application as a service. Meaning that once installed you can view its properties in the services menu of administrative tools. This allows you to choose whether or not your application will interact with the desktop, meaning that it can completely run undetected by the user. Also, you are able to select what occurs in the event the application fails, i.e. whether it should restart or execute another file. Also, a service can be set to start on start up and can also run while no user is logged into a machine.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  5. #5
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Swoosh ~~noise of it going over my head~~ Swoosh

    I dont even know what to ask next.
    What can i do with that code then (example)
    Where can I learn more?


  6. #6

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Post

    Thanks seoptimizer2001. I'll have to try an figure out how that code works. It seems a little odd, but maybe because i've never dealt with this before.

    Any tips would help.
    ~Peter


  7. #7
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    This code is actually very simple to use. I wish I remembered where I got it. What you need to do is first include this form in your project and make it your startup form. Then change the display name to whatever name you want to refer to this service and put a command at the end of the Form_Load event to load your actual first form that the user sees. Complie your app and now you are ready to install the service. From a command prompt navigate to the directory the .exe resides using the change directory function. Then type the name of the .exe and -install, ex. text.exe -install. Likewise you use -uninstall to uninstall the service. Now you can view your service and its properties in your services menu found in Administrative Tools. Good Luck, let me know if you have any problems.

    Oh, yeah, don't forget to register the ntservice control!
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  8. #8
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    Cool

    1 more thing..

    What are the advantages of this other that being running all the time and being invisible..

    That is all .

  9. #9
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Well, it doesn't have to run invisibly, you can decide whether or not it can interact with the desktop. I see two major advantages and reasons why I have used services in the past. One, it can run with out a user being logged in. And two, you are able to set recovery options for the service if it fails. Meaning that you can trap and error, if it is a 'fatal' error then you can exit the program and the service will restart itself in a minute. This is perfect when you have an app that needs to be able to run unattended 24/7.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  10. #10
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    yumm, hehe
    I remember I was trying to close some programs in win2k and it didn't give me permission to close them ( from the task manager).
    If your program is a service, can you do the same?

  11. #11
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    I am not sure about that, I have never tried. I will have to check on one of the boxes that is running my services to find out. I know that the way they are set up now, I can stop the program from task manager.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  12. #12

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    Okay, but then how does the user load the program? It'll run as a service, but how do i get the user into the prgram if it's wrapped up by your install service code.

    Could i not make this into a seperate file that installs/uninstalls my app?
    ~Peter


  13. #13
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    You could make a batch file that would install/uninstall the service. But in most cases a program that runs as a service is not one that a user is going to interact with. After you install the service, you will need to go into the services menu to select the properties of the service. Now you program can be run just as any other program is run even if it is not installed as a service, just needs to be installed if that is what you want it to do. I really wish I remembered where I got a lot of this code from, because it explained it a lot better. It probably can do more that what I have used it for.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  14. #14

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Post

    Well my app does have a interface for the user to edit the settings and such. So i would need something for them to make alterations with.
    ~Peter


  15. #15
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Then in this case let the service interact with the desktop, which will put an icon on the task bar to allow the user's interactions.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width