< Start programs time-delayed >

Time shifted execute of programs after system start-up

    Problem

    The computer takes ages to boot, so you're going to make a coffee while the system is loading. It would be nice to have the complete working area ready when you're coming back.

    Solution

    You can put all your important applications (like Internet browser, email, messenger, word processing, spreadsheet, ...) into the Start-up folder of your operating system. However there might be days when you need some programs only and waste a lot of time waiting for the rest to start. So, we need a way to cancel the start of software if necessary.
    This can be done in Linux and Windows with on-board software but not quite well with the Task Scheduler (Windows), the AT-command or a CRON-job (both in Linux). These applications are good for scheduled tasks mainly but not for this specific area. (e.g. Start a task 10 seconds or 5 minutes after system start or every day at noon.)

    Linux

    Tested in Ubuntu. Procedure for Debian, Mandriva, Mint, Red Hat, Fedora, CentOS, SuSE/openSuSE and other should be similar.

    > Shell script

    Using Zenity you can create a graphical user interface (GUI) in the Gnome-desktop environment and return the results to the console. The program is part of many Linux distributions already and don't has to be installed additionally. Alternatives (with a similar handling) are gdialog, dialog, Xdialog, cdialog or KDialog (KDE).

    #!/bin/bash
    zenity --question --timeout=30 --text="Starting programs in 30 sec." --title="Autostart"; STATUS=$?
    if [ $STATUS = "1" ]; then
    	echo ""
    else
    	firefox & thunderbird & openoffice.org & pidgin
    fi

    [img] Autostart Linux Zenity

    Explanation

    #!/bin/bash Using the BASH-Shell to execute the commands. (but it doesn't has to be /bash)
    --question Create a dialog with OK and Cancel button.
    --timeout=30 Wait 30 seconds for an input.
    --text="" Text to show.
    --title="" Title of window.
    STATUS=$? Saves the return value in variable $STATUS.
    if [ $STATUS = "1" ]; then If the return value is 1 (User hit "Cancel"), then ...
    echo "" ... print out nothing. (There has to be some command in the IF-branch.)
    else ... (Return value 0 = OK, 5 = TimeOut) ...
    program1 & program2 & ... Starting programs at the same time (don't wait for program1 to be finished).
    fi End of IF-branch.

    > Start Up

    The script has to be loaded at system start up.
    The file for system start up commands depends on your Linux distributions but is mainly in /etc/init* Fortunately, nobody has to deal with command line tools to create a start up entry nowadays but can use the system preferences or system management.

    > "Portable" Skype for Linux

    Windows versions of Skype offers the options /datapath and /removable to avoid saving personal data in the user directory. (See Windows or this article.)
    The Linux version has a similar option also called "--dbpath". To start Skype on an USB flash drive you can write the following on a console:

    /media/USB-flash-drive/Skype.ix/skype.real --dbpath=/media/USB-flash-drive/My-Skype-Data
    

    There have been problems starting the "skype.real"-file directly on an older system running OpenSUSE. Instead a shell script was called. The program starts from USB flash drive and saves its data in the HOME-directory again. If you close the "Portable Skype", all user data will be erased.

    #!/bin/sh
    LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so  /media/USB-flash-drive/Skype.ix/skype.real "$@"
    
    # Option 1: Delete the complete Skype-directory in HOME
    # Attention! All Skype-accounts in the actual Linux user profile are deleted!
    # rm -r ~/.Skype
    
    # Option 2: Delete only the personal Skype user profile in HOME
    rm -r ~/.Skype/my_Skype-username
    

    The script and the software can be found in /usr/bin after a Skype installation. You can easily copy it to your flash drive. Alternatively you can extract the skype files from the installation package on skype.com.

    Windows

    Tested in Windows XP. Procedure for Windows 2000, Windows Vista, Windows 7, Windows Server 2003, Server 2008 and other should be similar.

    > Visual Basic Skript (WSH, VBS)

    The Windows Scripting Host offers a command to create a PopUp question dialog.

    Dim result
    
    	set shell = CreateObject("WScript.Shell")
    	result = shell.PopUp ("Starting programs in 30 sec.",30,"Autostart?",48 + 1)
    
    	If result = 1 Then ' 1 = OK
    		startPrograms()
    	ElseIf result = 2 Then ' 2 = Cancel
    	'	do nothing
    	Else ' TimeOut
    		startPrograms()
    	End If
    
    Function startPrograms()
    
    	Set shell = CreateObject("WScript.Shell")
    	shell.exec("taskmgr.exe")
    	shell.exec("Z:\Internet\Mozilla Thunderbird\thunderbird.exe -P "+Chr(34)+"Username"+Chr(34)+"")
    	shell.exec("Z:\Internet\Mozilla Firefox\Firefox.exe")
    	shell.exec("Z:\Internet\Skype\Phone\skype.exe /datapath:"+Chr(34)+"Data"+Chr(34)+" /removable /nosplash /minimize")
    	shell.exec("explorer.exe X:\Documents and Settings\Username\My Files\Studies\Homework")
    	
    End Function

    [img] Autostart Windows VBS WSH

    Explanation

    Dim result Define a variable.
    set shell = CreateObject("WScript.Shell") Variable for Shell-Object.
    shell.PopUp("Text", Wait, "Title", Type) Open a window with text and title and wait 30 sec before closing it again.
    48 + 1 Create the window with OK- and Cancel button (1) and use an exclamation mark as icon (48).
    If Then ... ElseIf Then ... Else ... End If Conditions
    startPrograms() Function with a list of programs to start.
    shell.exec("taskmgr.exe") Open the Task Manager.
    shell.exec("Z:\Internet\Mozilla Thunderbird\thunderbird.exe -P "+Chr(34)+"Username"+Chr(34)+"") Start Thunderbird with profile of user "Username" (thunderbird.exe -P "Username").
    shell.exec("Z:\Internet\Mozilla Firefox\Firefox.exe") Start Firefox without a specific profile.
    shell.exec("Z:\Internet\Skype\Phone\skype.exe /datapath:"+Chr(34)+"Data"+Chr(34)+" /removable /nosplash /minimize") Start Skype in portable mode and minimized without splash screen. (skype.exe /datapath:"Data" /removable /nosplash /minimize). Useful for USB flash drives or encrypted drives.
    shell.exec("explorer.exe X:\Documents and Settings\Username\My Files\Studies\Homework") Open the folder using the windows explorer.

    > Start Up

    The script has to be loaded at system start up. Usually the start-up folder can be found under Start > Programs > Startup

    Hardware Start Up

    To start up the computer automatic at a specific time you will find an option in almost every modern computer's BIOS. (There is also an option to wake the computer via a network broadcast called wake on lan, WOL.) You can reach the BIOS (basic system preferences of your computer) on most computers by pressing the Delete-key or F2 before your operating system starts. Please consult the manual of your mainboard for further information. Also note, that the computer has to be energized all the time to start automatic and that a wrong setting in the BIOS may damage your hardware!

    Download

    You can download all script files for free also.


    Related topics: Downloads PC Shutdown TrueCrypt

    Rate page:  
      2.5/5 Points (10 Ratings)
    2.5/5 10