Delayed Startup

Why did I create a delayed startup program?  After I saw all the stuff my manager had booting up on his computer, I thought this may be useful.  His computer really wasn't terribly usable for a good 10 minutes after a reboot so I decided to spend a few minutes and create him a nice program while I'm at a .Net User Group meeting (they had free food and it was 1 floor up in my building).  My theory is most of the programs in your startup folder aren't actually needed asap.  I don't need OneNote open right away, I don't need a bunch of other stuff right away.  The nice thing is now I can have Visual Studio, Outlook, IE, and a few other programs I run everyday not impact me restarting my computer's bootup time since they'll do a gradual loading sequence.

Why isn't there an application to do the configuration file?  Because I'd hope someone could decipher 3 lines of XML.

Here is the source code (and the .zip file) and the installer

Source Code:

[STAThread]
static void Main()
{
    string startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
    string delayedStartupFolder = GetSetting("DelayedStartupFolderName", "Delayed Startup");

    int TimeDelayBeforeStartingSeconds = GetSetting("TimeDelayBeforeStartingSeconds", 10);
    int TimeDelayPerProcesssSeconds = GetSetting("TimeDelayPerProcesssSeconds", 5);

    DirectoryInfo di = new DirectoryInfo(startupPath);

    Thread.Sleep(TimeDelayBeforeStartingSeconds * 1000);
    string delayedFolder = Path.Combine(di.Parent.FullName, delayedStartupFolder);
    if (Directory.Exists(delayedFolder))
    {
        di = new DirectoryInfo(delayedFolder);

        FileInfo[] files = di.GetFiles();
        foreach (FileInfo file in files)
        {
            if (file.Extension.ToLower() != ".ini")
            {
                Process.Start(file.FullName);
                Thread.Sleep(TimeDelayPerProcesssSeconds * 1000);
            }
        }
    }
}

private static int GetSetting(string key, int defaultValue)
{
    int.TryParse(ConfigurationManager.AppSettings[key], out defaultValue);

    return defaultValue;
}

private static string GetSetting(string key, string defaultValue)
{
    return ConfigurationManager.AppSettings[key] ?? defaultValue;
}

App.Config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="DelayedStartupFolderName" value="Delayed Startup"/>
        <add key="TimeDelayBeforeStartingSeconds" value="10"/>
        <add key="TimeDelayPerProcesssSeconds" value="5"/>
    </appSettings>
</configuration>

Paul Abke Aug 13, 2008 @ 7:09 AM

# re: Delayed Startup
Do you have instructions on how to get your program to work? I kind of get the code, but am not sure where to start.

Clint Rutkas Aug 13, 2008 @ 11:42 AM

# re: Delayed Startup
Paul, what do you need help on exactly? If you opt for the installer, you just need to have a folder called "Delayed Startup" in your menu. Put all shortcuts that you want to start up after your system has.

If you want the time delays bigger, modify the app.config file.

skagon Nov 7, 2008 @ 8:53 AM

# re: Delayed Startup
Where exactly does that "Delayed Startup" thing have to be? In Start->Programs->StartUp, Start->Programs, or is it a subdirectory in "Delayed Startup"'s main directory?

Clint Rutkas Nov 10, 2008 @ 2:46 AM

# re: Delayed Startup
@skagon start->programs->"delayed startup"

skagon Nov 11, 2008 @ 4:04 AM

# re: Delayed Startup
I just found out that the folder has to be under:
[system drive]:\Documents and Settings\[user name]\Start Menu\Programs\Delayed Startup
otherwise it doesn't start anything -- if, for example, it's under "All_Users".
That's a helpful hint.

Clint Rutkas Nov 16, 2008 @ 7:20 PM

# re: Delayed Startup
This is setup programmatically. So how it works is it determines where *Windows* (depending on how an admin sets up your box, this can alter) thinks your start up directory is. From there it goes up one directory then attempts to see "delayed startup" as a folder.

So to determine where yours will be, go to start->programs->start up folder, right click->properties

From there see where the location label is and that will tell you where your startup folder is.

captain terror Mar 13, 2010 @ 5:14 PM

# re: Delayed Startup
hi!

i'm running vista 64-bit, and i wonder if that's what's preventing this from working for me...

What i've done:
1. installed the program from setup.exe
2. deposited "Delayed Startup" directory to where mine points to from properties of start/programs:
C:\Users\captain_terror\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
3. placed two programs in the "Delayed Startup" directory (utorrent and speedfan).

upon reboot, the only thing that happens is the Delayed Startup folder contents (utorrent and speedfan) are displayed. After no amount of time will either start though..

Also, im curious why there are to config files:
app.config
delayedstartup.exe.config

each containing identical info. is app.config a template to stagger programs at different times, like:
utorrent.exe.config
SpeedFan.exe.config

each with their own individual startup times?

I'm confused and i obv don't code at all.. Please advise if you have the time1
= )

captain terror Mar 13, 2010 @ 5:19 PM

# re: Delayed Startup
just thought of something else that is probalby pertinent. each of the programs i'm trying to delay start are not in the same directory as the delayed startup installer. DSI is in c:\program files\clint rutkas.., and my two delay progams are located D:\program files\...

Sorry i didn't think of this sooner. i'll try delay-starting something from the c:\program files\ directory, and see if that works..

= )

Post a Comment

Please add 1 and 8 and type the answer here: