Windows features you didn’t know existed: start /b and start /priority

In popular Unix/Linux shells, there is an option to start a process in the “background” by (i.e. in bash) typing “./something &“, or 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.

In Windows, something similar (much less powerful than the bash “jobs”, though) can be done by doing: start /b something

This runs the process in the background, and its output is printed to your stdout, even though cmd continues running immediately and receives your stdin. (If the process tries to read from stdin, weird things happen that I can’t explain.)

If you do “start something” without the “/b” switch, the process runs in another window, which closes when it exits.

Another switch for “start” is /priority, where priority is the name of a process priority. This can be combined with /b to give you:

start /b /realtime pslist

to get a pslist output that runs in realtime priority.

Important note about this: You may think this is unnecessary if your cmd already runs in high priority, because the priority will carry on to the child process by default anyway, right?

Wrong! Here is the relevant excerpt from the documentation of the CreateProcess function:

[in] Flags that control the priority class and the creation of the process. For a list of values, see Process Creation Flags.This parameter also controls the new process’s priority class, which is used to determine the scheduling priorities of the process’s threads. For a list of values, see GetPriorityClass. If none of the priority class flags is specified, the priority class defaults to NORMAL_PRIORITY_CLASS unless the priority class of the creating process is IDLE_PRIORITY_CLASS or BELOW_NORMAL_PRIORITY_CLASS. In this case, the child process receives the default priority class of the calling process.

Well, that was news to me, anyway.

I really recommend reading start /? and cmd /?, to catch up with the other cool features you didn’t know about.


11 Responses to Windows features you didn’t know existed: start /b and start /priority

  1. Thanks a lot for taking your time to provide this cool information.

    Once i used to program the Win32 API, but nowadays i don’t. So, your hints came up handy to provide the tricks needed for the Win32 programming.

    All the best,

  2. Use HIGH_PRIORITY_CLASS with care. If a thread runs at the highest priority level for extended periods, other threads in the system will not get processor time. If several threads are set at high priority at the same time, the threads lose their effectiveness. The high-priority class should be reserved for threads that must respond to time-critical events. If your application performs one task that requires the high-priority class while the rest of its tasks are normal priority, use SetPriorityClass to raise the priority class of the application temporarily; then reduce it after the time-critical task has been completed. Another strategy is to create a high-priority process that has all of its threads blocked most of the time, awakening threads only when critical tasks are needed. The important point is that a high-priority thread should execute for a brief time, and only when it has time-critical work to perform.

  3. Hi, the whole thing is going fine here and ofcourse
    every one is sharing facts, that’s genuinely fine, keep up writing.

  4. Recent study published in a business journal in 2009 indicates 69% of
    businesses that venture into the NEMT business abandon the start up process.
    Home health care nurse are specialized in caring for disabled children,
    which require additional care and patience. In this case, Chevron USA plans
    to build a new downtown office building on Louisiana Street, transferring 800 jobs from its California headquarters and creating
    1700 new professional jobs with salaries averaging $110,000 a year.

  5. This is my first time visit at here and i am truly happy to read all at
    single place.

  6. Great website. A lot of helpful information here. I am
    sending it to some pals ans additionally sharing in delicious.
    And certainly, thank you in your sweat!

  7. href="" title="rail work nottingham">rail work nottingham says:

    I value the post. Awesome.

  8. gas-fired heater versus

    Windows features you didn

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: