I have problem with using QProcess class to format pendrive. I checked similar questions, but they didn't help me. How can I enter a few commands to diskpart.exe? It should be something like this?
QProcess process;
process.start("diskpart.exe",QStringList()<<"/C"<<"select disk 1"<<"clean");`
Because it doesn't work, I tried also other solutions, but without result.
QString command("diskpart.exe");
QStringList params=QStringList()<<"/k"<<"select disk 1"<<"clean";
QProcess::startDetached(command,params);
The code above opens diskpart and immediately closes it without cleaning disk. Why is this happening?
I would like to ask about running commands from txt file also, if I write them to txt file:
select disk 1
clean
How to execute this? Because I failed with this too. One more other question, how can I check a letter of pendrive in diskpart in c++? To select a specific pendrive which I select in comboBox in my program?