How to run .exe file from absolute path with button click
-
wrote on 6 Aug 2014, 10:24 last edited by
can any one help me exactly where i have to keep that .exe file which should open on buttton click.
-
wrote on 6 Aug 2014, 10:42 last edited by
The location of your exe is basically irrelevant. More important is the presense of required dlls. Checkout for "this for more details.":http://qt-project.org/doc/qt-5/windows-deployment.html
-
wrote on 6 Aug 2014, 10:44 last edited by
i need the code of button-click event.(just to run some patcher.exe file)
-
wrote on 6 Aug 2014, 11:14 last edited by
If you use QProcess::startDetached you can start the program in any "working directory". Just mention it in the 3rd parameter.
-
wrote on 6 Aug 2014, 11:44 last edited by
QString fullProgramPath =QDir::currentPath();
fullProgramPath.append("/Patcher.exe");
QStringList arguments;
arguments << "install";
QProcess::startDetached(fullProgramPath, arguments);anything wrong in it?
-
wrote on 6 Aug 2014, 11:53 last edited by
This should work if Patcher.exe is located parallel to the program you are running,
But it may become wrong if you change the current directory during the run of your program.
-
wrote on 6 Aug 2014, 12:00 last edited by
actually what i need to do is...
i should install an exe on button click.The things i need to understand
1.Where should i place that exe file in my application
2.How to run that through code -
Can you try something very simple now from your main.
@ QProcess *proc = new QProcess;
QString progName = "c:/users/madhavi/Patcher";
proc->start(progName);
proc->errorString()
@
I'm assuming that your exe is in c:/users/madhavi directory. If you are able to run this, your first step is solved.Now.
@ connect(pushButton,SIGNAL(clicked()),this,SLOT(launchPatch()));
void MyClass::LaunchPatch(){
qDebug() << "Show the Calcualtror"<<endl;QProcess *proc = new QProcess; QString progName = "c:/users/madhavi/Patcher"; proc->start(progName); proc->errorString() proc->errorString(); qDebug()<< " Started the process"<<endl;
}
@This should solve your issue.
-
wrote on 7 Aug 2014, 12:44 last edited by
not working...:(
-
what is not working ? What is the error you get ? If you can paste your code we can help you better.
-
wrote on 8 Aug 2014, 03:25 last edited by
i used the same.Am not getting any error message and no output. I used startDetached also. but still am not getting any output atleast error.
-
If you can drop your code and how you are trying that will help. Can you try with some other executable to start the program ? This is just ensure that you don't have any problem starting new process from Qt.
-
wrote on 9 Aug 2014, 20:53 last edited by
yes thank you. the problem is with exe file. I tried another exe as u said,it is working fine. finally got solution.:)
-
This is cool. How about moving this Question to SOLVED state by editing the subject line of your question ?
-
wrote on 11 Aug 2014, 10:41 last edited by
actually am trying to execute 4.50MB file(exe size)..is that that problem ?
-
wrote on 11 Aug 2014, 11:17 last edited by
QProcess *proc = new QProcess; QString progName ="C:/Patcher"; proc->start(progName); proc->errorString();
-
4.5 MB is not a issue at all. Is it not running ? May be there is dependency with some libraries. Check it.
-
wrote on 11 Aug 2014, 14:19 last edited by
i can run that exe directly.but not able through code...
-
wrote on 11 Aug 2014, 20:51 last edited by
finally got solution by using
QDesktopServices::openUrl(QUrl("file:///"+progName,QUrl::TolerantMode)); -
What is the error string you get ? I suspect the issue with dependency dlls not in path. Launching 4.5 MB exe is not issue.
1/21