0

我尝试使用 QProcess 通过 diskpart 获取信息,如下所示:

  • 在文本脚本“list.txt”中,我写道:
   list disk
  • 在 cpp 中:

    QProcess proc;
    proc.start("C:/Windows/system32/diskpart.exe", QStringList()<<"/s"<<""C:/Windows/system32/list.txt);
    proc.waitForFinished();
    
    

但没有任何反应,因为我没有得到 Diskpart 的对话框(用于 ACL)。如果我添加 proc.waitForStarted() 以查看进程是否启动,我没有得到确定。

我还尝试单独启动 diskpart:

     proc.start("C:/Windows/system32/diskpart.exe");
     if (proc.waitForStarted())
         ui->tText->append("Process started");
     else ui->tText->append("Process not started");
     proc.waitForFinished();

我得到'没有开始'

如果我使用

     system("diskpart");

diskpart 启动。但我无法将脚本用于:

     system ("diskpart /s "C:/Windows/system32/list.txt");

错误在哪里?

4

0 回答 0