Results 1 to 18 of 18

Thread: Execution of program during login

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Execution of program during login

    Hi,
    I have a program which has to run on the administrator machine continuously. The problem is if the user logs off, the process gets stopped and a lot of users use the administrator machine daily(log in with their id and log off). I want to invoke my program each time a user logs in.How do i do that. Can i use scheduled tasks. if so how do i do that. Can anyone help me out.

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Execution of program during login

    Add it to the Start-Up or just change it to w Windows Service. Windows Service run even when noone is logged in.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: Execution of program during login

    How do I change it to a Windows service. I do not know anything about that. Can you tell it in detail.

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Execution of program during login

    Quote Originally Posted by Chandana Sameera
    How do I change it to a Windows service. I do not know anything about that. Can you tell it in detail.
    If all the program does is some background processing then you can convert it to a Windows Service. Also remember Windows services do not have a User Interface. So if your application has a User Interface then it is better to add it to the Start-Up folder in the Programs window.

    To create a Windows Service you will need a control named NTSVC.OCX. I tried searching for it on MS few days back but I think as VB 6 is not supported anymore so they have removed it from the site. You can do a search here or at www.planetsourcecode.com for a quick sample of developing a Windows Service in VB 6.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: Execution of program during login

    It has a user interface. It actually connects to a database retrieves information anf fills up excel sheets everyday at a particular time. The problem is only with the logging off. It stops once theuser logs off. Will it stop if user logs off in case i place in startup and if we place in startup will it start when user logs in or when the system is started. Can you tell me in detail how to add it to startup. I tried but it was not working.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Execution of program during login

    or you can use srvany to run your program as a service, do a search on "servany"

    pete

  7. #7
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Execution of program during login

    Quote Originally Posted by Chandana Sameera
    It has a user interface. It actually connects to a database retrieves information anf fills up excel sheets everyday at a particular time. The problem is only with the logging off. It stops once theuser logs off. Will it stop if user logs off in case i place in startup and if we place in startup will it start when user logs in or when the system is started. Can you tell me in detail how to add it to startup. I tried but it was not working.
    Any application that is running under a particular user account does stop once the user logs off. Even if you have added an application to the startup it will start automatically but once the user logs off it will stop.

    Try to add it to Scheduled Tasks and see if it runs properly.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Execution of program during login

    add a shortcut in the all users start folder

    it should then start whenever anyone logs in

    pete

  9. #9
    Hyperactive Member BillGeek's Avatar
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    440

    Re: Execution of program during login

    Hi

    It's a bit confusing to let an application run when there's no user logged-in. If the application is allowed to end when the user logs-off, but should run as soon as another user logs on, and you don't mind "fiddling" with the registry, I might have a solution for you......

    Open REGEDIT.EXE

    Create a new "String Value" in the registry under the following key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

    Give it an appropriate name and enter the path of your application as a value.

    So, for example, you'll have a new string value as follows:
    NAME: MyApp
    VALUE: "C:\Program Files\My App\MyApp.exe"

    This will run the program when any user logs on to the system.

    Hope it helps!

    The reason why I prefer entering it to the registry, is so that end-users cannot "access" it as easily as the shortcuts in the "All Users" startmenu folder. EG: They can delete the shortcut no problem, but in the registry, they'll have quite a hard time to find and delete the value...
    Last edited by BillGeek; Jul 10th, 2006 at 08:05 AM. Reason: Forgot to mention...

  10. #10

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: Execution of program during login

    My project has two parts. One is an automation tool that runs always and a configuration ool to configure my automation tool. When i am configuring the automation tool has to stop execution and when i stop the configuration tool i want to launch it once again. But now my automation tool is running as a service. Is there any way to start and stop the services through VB. Does anyone know that. If it is not possible can anyone suggest an alternative.

  11. #11
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Execution of program during login

    maybe this thread of mine can help

    http://vbforums.com/showthread.php?t=397508
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  12. #12

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: Execution of program during login

    But will it run the program even during logoff or will it run only if someone is logged on

  13. #13
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Execution of program during login

    that code in the thread sets the program to run at startup. it is intended to be executed in a separate application.

    if that code is executed successfully, the program you set to run at startup will execute everytime you open your pc or log on to it.
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  14. #14

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: Execution of program during login

    What should HKEY_CURRENT_USER be defined as. It is giving a compile time error

  15. #15
    Lively Member
    Join Date
    Jan 2006
    Posts
    114

    Re: Execution of program during login

    Hklu

  16. #16
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Execution of program during login

    Is there any way to start and stop the services through VB. Does anyone know that. If it is not possible can anyone suggest an alternative.
    you could use NET STOP to stop a service

    pete

  17. #17

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: Execution of program during login

    Can we register an EXE as a windows service manually. If so how can we do it. Can anyone tell it to me in detail.

  18. #18
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Execution of program during login

    vb applications are not normally able to run as a service, though there are several ways to get round that problem.

    there is an ocx that can be added to a project
    there is sample code someplace, google "run service"
    or there is a service (by microsoft) that will run other applications as a sevice, which is the best (only?) solution for software written by some one else google "srvany"


    there are limitations as to what programs can do when run as a service

    i have a "stay on top" vb exe i wrote and run as a service using srvany, but every so often (maybe once a week or 2) it gets lost and i have to use task manager to to switch to itand bring it back on top

    pete
    Last edited by westconn1; Jul 11th, 2006 at 04:53 AM.

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