Hello Gurus,
I need to execute a vbs script from inside QT Proc, in order to read machine data
VBS script prints the output to the console and works fine .. but
I inserted the script into a resource and since then, i can not call the script from the resource probably because it is compiled at run time
so the other idea i came to is to read the script from the resource .. but how can i pass the QStringList to the Proc as a parameter to the "cscript.exe" file
following is my code
@
#include "winserial.h"
#include "ui_winserial.h"
#include <QProcess>
#include <QDebug>
#include <QFile>
#include <QString>
#include <QTextStream>
QStringList WinSerial::Read(QString Filename)
{
QFile mFile(Filename);
QStringList arg;
if(!mFile.open(QFile::ReadOnly | QFile::Text))
{
qDebug() << "could not open file for reading";
return arg;
}
QTextStream in(&mFile);
QString mText = in.readAll();
mFile.close();
arg << mText;
return arg;
}
WinSerial::WinSerial(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::WinSerial)
{
//ui->setupUi(this);
QProcess proc;
QStringList arg;
//proc.start("D:/Activate Software/typing tutor MAC/macserial/win.vbs");
QFile file(":/win.vbs");
arg = Read(":/win.vbs");
qDebug() << arg; // this reads the string correct
QString name = "cscript" ;
proc.start("cstring" , arg); // this does not work, in windows we would write cscript win.vbs but the file is a QStringList in memory
proc.waitForFinished();
QString uID = proc.readAll();
uID.remove("\n");
}
WinSerial::~WinSerial()
{
delete ui;
}
@
Bookmarks