Link to home
Start Free TrialLog in
Avatar of McDorman
McDorman

asked on

Repost: Order of Start Up Applications

This is a repost of my earlier question: Order of Start Up Applications.  Please submit your comments, and I will issue a message to the most suitable answerer to then obtain the points.

Thanks

Tom
Avatar of linschoten
linschoten

I think you can order the startup by moving the icons. However you can either run the jobs from a batch file and put a shortcut to the batch file in the startup group or you can run the individual programs from the RUN and/or LOAD commands in the WIN.INI file

Ok here I go again:-

Writing a utility to start programs in a particular order, and then pausing between the start of each program to ensure they appear in the correct order, is pretty easy. The follow program takes a list of program paths and delays as arguments. The easiest method to use it is to place a shortcut to this program in the startup directory with the correct target info. For example;-

A target string could look like.

c:\myprogs\thisprogram.exe c:\program files\first_program.exe 2 c:\program files\second_program.exe 3 c:\program files\third_program.exe 0

This would start c:\program files\first_program.exe wait 2 secs, then start  c:\program files\second_program.exe wait 3 secs and then finally start c:\program files\third_program.exe

If you dont have a vc++ complier I can email you a working version of
this. Or if you need any more help on how to use it, let me know.

    #include <afx.h>
    #include <iostream.h>
    #include <winbase.h>
    #include <process.h>


    int main(int argc, char *argv[])
    {
     PROCESS_INFORMATION ProcessInfo;
     STARTUPINFO  InfoToPass;
     int   seconds;
     int   currentArg = 1;



     // Initialise Startup structure
     InfoToPass.cb = sizeof(InfoToPass);
     InfoToPass.lpReserved = NULL;
     InfoToPass.lpDesktop = NULL;
     InfoToPass.lpTitle = NULL;
     InfoToPass.dwFlags = STARTF_USESHOWWINDOW;
     InfoToPass.cbReserved2 = 0;
     InfoToPass.lpReserved2 = NULL;
     InfoToPass.wShowWindow = SW_SHOWNORMAL;

     // Spawn required process as a normal process

     while (currentArg < argc)
     {
      // You could also use winexec here, but i prefer the control achived using
      CreateProcess(argv[currentArg++], "", NULL, NULL, FALSE,
       CREATE_NEW_CONSOLE, NULL, NULL, &InfoToPass, &ProcessInfo);


      sscanf(argv[currentArg++],"%d", &seconds);

       // wait
      Sleep(seconds * 1000);
     }

     return (0);

    }


Note:- I prefer to use createprocess() over winexec() due to the additional control it gives you over the process. Also, replacing  SW_SHOWNORMAL with SW_SHOWMINISMED allows an application to start minimsed on the task bar. It would be quite simple to add this to the list of arguments at start up.
actually a program already exists to do just that and is freeware.  Its called DoWinStartup and is available at
http://www.mrdo.com/dowinstartup
has alot of other cool features (like delayed loading of programs) and is much beter than writing your own program IMHO.
Avatar of McDorman

ASKER

I'm going to reject this answer due to 2 other better answers.  rlippert would you please post your comment as an answer to this question.  Arunm, I'll give your answer the points on the original answer to this question.

Although both your answers were very good, I took my wife's computer off the ISDN network and gave her a regular modem, which works well from within Outlook itself.

Thanks

Tom
ASKER CERTIFIED SOLUTION
Avatar of rlippert
rlippert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial