I am making an application that adds a new user account on Windows, in Qt Creator. The application asks for a username and password, then opens the cmd and enters the command net user username password /all. I want to be able to make a label that is always equal to what the cmd returns after the command has been input, for example "This account already exists". My code is below.
#include <QDebug>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QProcess"
#include "QTextStream"
#include <iostream>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QProcess process1;
QStringList arguments1;
arguments1 << "net user" << ui->lineEdit->text() << ui->lineEdit_2->text() << "/add";
QString path = "C:/Windows/system32/WindowsPowerShell/v1.0/powershell.exe";
process1.execute(path, arguments1);
QString output(process1.readAllStandardOutput());
ui->label_4->setText(output);
}