How to get list of activated and deactivated module using some script from database?
For disabled modules:
SELECT * FROM system WHERE type='module' AND status=0

For enabled modules:
SELECT * FROM system WHERE type='module' AND status=1

If you need to do this using drupal functions, you can try something like:

    $query = db_select('system', 's')
    -&gt;fields('s', array('name', 'weight'))
    -&gt;condition('type', 'module')
    -&gt;condition('status', 0);
    $result = $query-&gt;execute();

    foreach ($result-&gt;fetchAll() as $record) {
      // do something here...
    }


And process the results from $result.