Thursday, February 17, 2011

Starting process in background in windows using : start /b and start /priority

This information that I am posting came as a surprise to me two years back. And sine one year I have seen its usage groeing in my day to day job at Software Divisions of MNCs. Jokes apart, various automations that I did used the following concept in some way or the other. Sometimes the bat scripts and some times the python scripts.


Actually in Unix/Linux shells and hence in beautiful Mac machines I owned at Adobe Systems, there was an option to start a process in the “background” by (i.e. in bash) typing “./&“, or you may try pressing Ctrl-Z and then “bg“. The process then prints its output to stdout as usual, but the bash runs in the foreground and receives console stdin. The task was easy.

But in Windows, mere calling the exe would not do this job that easily done. But something similar can be done by doing: start /b . This would run the process in the background, and its output is printed to your stdout, even though cmd continues running immediately and receives your stdin. Be warned that if you do “start ” without the “/b” switch, then the process runs in another window, which closes when it exits.


There is yet another switch for “start” is /priority, which I learnt only after joining Symantec Software. In this command the ‘priority’ is the name of a process priority string. For example “start /b /realtime pslist” can be used to get a pslist output that runs in realtime priority.

No comments:

Post a Comment