How to enter commands to diskpart using QProcess

Multi tool use


How to enter commands to diskpart using QProcess
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");
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.
I would like to ask about running commands from txt file also, if I write them to txt file:
select disk 1
clean
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?
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.