Results 1 to 3 of 3

Thread: how to run a vbs script in resource from inside QT

  1. #1
    Join Date
    Sep 2013
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default how to run a vbs script in resource from inside QT

    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;
    }

    @

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to run a vbs script in resource from inside QT

    Create file on disk (best in tmp dir) and then run script executor with full path to this file.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to run a vbs script in resource from inside QT

    Also see QTemporaryFile

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 16th July 2012, 09:56
  2. Running a bash script from resource (qrc) file
    By onamatic in forum Qt Programming
    Replies: 4
    Last Post: 3rd February 2012, 10:09
  3. Use a QAbstractTableModel inside a QML script
    By zuck in forum Qt Programming
    Replies: 0
    Last Post: 7th January 2010, 16:16
  4. Can I include a script from script?
    By yycking in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2009, 03:01
  5. QLocale/Resource
    By coderbob in forum Newbie
    Replies: 4
    Last Post: 21st November 2007, 20:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.