Accurate evaluation of consciousness in patients with prolonged disorders of consciousness (DOC) is critical for designing therapeutic plans, determining rehabilitative services, and predicting prognosis. Effective ways for detecting consciousness in patients with DOC are still needed. Evaluation of the residual awareness in patients with DOC and investigation of the spatiotemporal differences in the hemodynamic responses between the minimally conscious state (MCS) and the unresponsive wakefulness syndrome (UWS) groups using active command-driven motor imagery (MI) tasks. In this study, functional near-infrared spectroscopy (fNIRS) was used to measure the changes of hemodynamic responses in 19 patients with DOC (9 MCS and 10 UWS) using active command-driven MI tasks. The characteristics of the hemodynamic responses were extracted to compare the differences between the MCS and UWS groups. Moreover, the correlations between the hemodynamic responses and the clinical behavioral evaluations were also studied. The results showed significant differences in the spatiotemporal distribution of the hemodynamic responses between the MCS and UWS groups. For the patients with MCS, significant increases in task-evoked hemodynamic responses occurred during the "YES" questions of the command-driven MI tasks. Importantly, these changes were significantly correlated with their coma-recovery scale-revised (CRS-R) scores. However, for the patients with UWS, no significant changes of the hemodynamic responses were found. Additionally, the results did not show any statistical correlation between the hemodynamic responses and their CRS-R scores. The fNIRS-based command-driven MI tasks can be used as a promising tool for detecting residual awareness in patients with DOC. We hope that the findings and the active paradigm used in this study will provide useful insights into the diagnosis, therapy, and prognosis of this challenging patient population.