lib/ms-task.js
function procStat( proc, callback ){
    var type = isNumber( proc ) ? 'PID' : 'IMAGENAME',
        arg = '/fi \"' + type + ' eq ' + proc + '\" /fo CSV',
        row = null,
        processes = {
            array: [],
            object: []
        };

    taskList( arg, function( err, stdout ){
        csv.parse( stdout, function( err, rows ){
            if ( rows.length > 0 ){
                for ( var i = 1; i < rows.length; i++ ){
                    row = rows[ i ];

                    processes.array.push( row );
                    processes.object.push({
                        name: row[ 0 ],
                        pid: row[ 1 ],
                        sessionName: row[ 2 ],
                        sessionNumber: row[ 3 ],
                        memUsage: row[ 4 ]
                    })
                }
            } else {
                var noun = isNumber( proc ) ? 'PIDs' : 'process names';
                err = new Error( 'There were no ' + noun + ' found when searching for \"' + proc + '\"' )
            }

            callback( err, processes )
        })
    })
}
function procStat( proc, callback ){
    var type = isNumber( proc ) ? 'PID' : 'IMAGENAME',
        arg = '/fi \"' + type + ' eq ' + proc + '\" /fo CSV',
        row = null,
        processes = {
            array: [],
            object: []
        };

    taskList( arg, function( err, stdout ){
        csv.parse( stdout, function( err, rows ){
            if ( rows.length > 0 ){
                for ( var i = 1; i < rows.length; i++ ){
                    row = rows[ i ];

                    processes.array.push( row );
                    processes.object.push({
                        name: row[ 0 ],
                        pid: row[ 1 ],
                        sessionName: row[ 2 ],
                        sessionNumber: row[ 3 ],
                        memUsage: row[ 4 ]
                    })
                }
            } else {
                var noun = isNumber( proc ) ? 'PIDs' : 'process names';
                err = new Error( 'There were no ' + noun + ' found when searching for \"' + proc + '\"' )
            }

            callback( err, processes )
        })
    })
}
function procStat ( proc , callback ) { var type = isNumber ( proc ) ? 'PID' : 'IMAGENAME' , arg = '/fi \"' + type + ' eq ' + proc + '\" /fo CSV' , row = null , processes = { array : [ ] , object : [ ] } ; taskList ( arg , function ( err , stdout ) { csv . parse ( stdout , function ( err , rows ) { if ( rows . length > 0 ) { for ( var i = 1 ; i < rows . length ; i ++ ) { row = rows [ i ] ; processes . array . push ( row ) ; processes . object . push ( { name : row [ 0 ] , pid : row [ 1 ] , sessionName : row [ 2 ] , sessionNumber : row [ 3 ] , memUsage : row [ 4 ] } ) } } else { var noun = isNumber ( proc ) ? 'PIDs' : 'process names' ; err = new Error ( 'There were no ' + noun + ' found when searching for \"' + proc + '\"' ) } callback ( err , processes ) } ) } ) }
Search for a given process name or PID
Search for a given process name or PID