"background processes" in Windows

In order to prevent my Windows machine from trying to start umpteen different applications simultaneously and thrashing to oblivion, I have written this script:

#!/bin/sh

TODAYFILE="$USERPROFILE/My Documents/$(date +%b%d-%Y.txt)"

[ -e "$TODAYFILE" ] ||
        touch "$TODAYFILE"

# ( notepad.exe "$TODAYFILE" ) &

cd "$USERPROFILE/Start Menu/Programs/Delayed-Start" || exit 1

set -- *.*

while [ "$#" -gt 0 ]
do
        printf "Starting %30s\r" "$1"
        case "$1" in
        *.[sS][hH])
                sh ./"$1" &
                ;;
        *)
                cmd /C "$1" &
                [ -z "$2" ] || sleep 45
                ;;
        esac

        shift
done

echo Done

It is executed by a batch file in my 'Startup' items (and Busybox's help.). It looks for script files, lnk files, or anything else inside my own 'Delayed Start' menu and waits 45 seconds between starting each application, in alphabetical order. I name them 1-firstapp 2-secondapp etc to determine the order.

You will notice one commented out line:

# ( notepad.exe "$TODAYFILE" ) &

This is because Notepad, unlike most "big" apps, doesn't put itself into the background -- and I can't force it to do so, even with & and a subshell. I guess this is something Windows must do, not something a mere script has power over.

How can I convince Windows to do this?

Use "start ..." or "start /B ..." from a batch file?

1 Like

Thanks, cmd /C "start /B ..." does the trick.