Running EXE's
-
I'm not sure where little helps and tidbits of knowledge goes in the forum. I have had lots of problems recently on getting some exe files to actually run in QT. Through searching the internet and asking around, I have seen 3 different ways to do it, so I thought I would share, just in case someone else ran across any issues on running programs through QT.
I'm sure this is basic for many people, but having a post like this would of helped me out tremendously when I started. It took like 3 days of almost non stop searching to come up with these ways of working with exe programs. Strange that one way doesn't work, so you have to do it another way, and if that doesn't work, then another way. But, in the end... ONE of these ways will work with ANY exe file that you are wanting to work, so hope it helps someone, and sorry if it's on the wrong section.
I've found out there are about 3 different ways to run exe programs. When one doesn't work, the other 2 will lol. At least one of them will anyway. Since I'm here, I'll list the four different ways that I've found for others that may have any similar issues:
1. QDesktopServices::openUrl(QUrl("file:///C:/windows/notepad", QUrl::TolerantMode));
2. system("C:/WINDOWS/system32/osk.exe");
3. QProcess::startDetached("\"C:\\Program Files\\WinHTTrack\\WinHTTrack.exe\"");
You can also use the shell command to open certain windows as well
system("%windir%/explorer.exe shell:::{4234d49b-0245-4df3-b780-3893943456e1}");
The above will open Applications, which will show every program/application you have on your computer.
Or the recycling Bin:
system("explorer.exe shell:RecycleBinFolder");
Or as another example, your internet trouble shooting:
system("msdt.exe -id NetworkDiagnosticsWeb");
Or you may want to run a DVD using VLC?
QProcess::startDetached("\"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe\" H:\\Movies\\Harry_Potter_Year_2\\Chamber_Of_Secrets\\VIDEO_TS.IFO\"");
-
If it's helpful, here is a list of commonly used System Programs for Windows 10
Command Prompt
QProcess::startDetached("\"C:\\Windows\\System32\\cmd.exe\"");
Control Panel
QProcess::startDetached("\"C:\\Windows\\System32\\control.exe\"");
Magnifier
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/Magnify.exe", QUrl::TolerantMode));
Registry Edit
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/regedt32.exe", QUrl::TolerantMode));
Services
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/services.msc", QUrl::TolerantMode));
System Info
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/msinfo32.exe", QUrl::TolerantMode));
Settings
QDesktopServices::openUrl(QUrl("file:///C:/settings", QUrl::TolerantMode));
Explorer
system("explorer.exe");
Task Manager
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/Taskmgr.exe", QUrl::TolerantMode));
Disk Cleanup
QProcess::startDetached("\"C:\\Windows\\System32\\cleanmgr.exe\"");
MsConfig
system("C:/Windows/System32/msconfig.exe");
Windows Remote
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/msra.exe", QUrl::TolerantMode));
Resource Monitor
QProcess::startDetached("\"C:\\Windows\\System32\\resmon.exe\"");
System Repair Discs
system("C:/Windows/System32/recdisc.exe");
Memory Diagnostics
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/MdSched.exe", QUrl::TolerantMode));
System Restore
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/rstrui.exe", QUrl::TolerantMode));
Startup Folder
QDesktopServices::openUrl(QUrl("file:///C:/Users/dclar.DESKTOP-JTNNAGR/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup", QUrl::TolerantMode));
Run Command
system("c:/windows/system32/rundll32.exe shell32.dll,#61");
Drive Optimization
QProcess::startDetached("\"C:\\Windows\\System32\\dfrgui.exe\"");
Disk Managment
system("C:/Windows/System32/diskmgmt.msc");
Computer Managment
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/CompMgmtLauncher.exe", QUrl::TolerantMode));
Text Tuner
QProcess::startDetached("\"C:\\Windows\\System32\\cttune.exe\"");
Computer Services
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/dcomcnfg.exe", QUrl::TolerantMode));
Device Manager
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/devmgmt.msc", QUrl::TolerantMode));
Direct X Diagnostics
QProcess::startDetached("\"C:\\Windows\\System32\\dxdiag.exe\"");
File History
QProcess::startDetached("\"C:\\Windows\\System32\\FileHistory.exe\"");
Blue Tooth Transfer
QProcess::startDetached("\"C:\\Windows\\System32\\fsquirt.exe\"");
Add Hardware
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/hdwwiz.exe", QUrl::TolerantMode));
Disc Label
QProcess::startDetached("\"C:\\Windows\\System32\\label.exe\"");
Language Installer
QProcess::startDetached("\"C:\\Windows\\System32\\lpksetup.exe\"");
Malicious Software remover
QProcess::startDetached("\"C:\\Windows\\System32\\MRT.exe\"");
Narrator
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/Narrator.exe", QUrl::TolerantMode));
User Accounts
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/Netplwiz.exe", QUrl::TolerantMode));
Windows Backup
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/sdclt.exe", QUrl::TolerantMode));
Create Shared Folders
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/shrpubw.exe", QUrl::TolerantMode));
System Shutdown
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/shutdown.exe", QUrl::TolerantMode));
Sticky Notes
QProcess::startDetached("\"C:\\Windows\\System32\\StikyNot.exe\"");
System Reset
QDesktopServices::openUrl(QUrl("file:///C:/Windows/System32/systemreset.exe", QUrl::TolerantMode));
Ease Of Access
QProcess::startDetached("\"C:\\Windows\\System32\\Utilman.exe\"");
Word Pad
QProcess::startDetached("\"C:\\Windows\\System32\\write.exe\"");
-
@Epiales666 said in Running EXE's:
- QString cmd = QString(""C:\Program Files (x86)\Notepad++\notepad++.exe"");
This does not start any executable, it just creates a string variable containing a path to an executable.
To avoid escaping of backslashes you can use / in Qt even on Windows:QString cmd = QString("\"C:/Program Files (x86)/Notepad++/notepad++.exe\"");
-
@jsulm said in Running EXE's:
@Epiales666 said in Running EXE's:
- QString cmd = QString(""C:\Program Files (x86)\Notepad++\notepad++.exe"");
This does not start any executable, it just creates a string variable containing a path to an executable.
To avoid escaping of backslashes you can use / in Qt even on Windows:QString cmd = QString("\"C:/Program Files (x86)/Notepad++/notepad++.exe\"");
Ah....Okay... ty for pointing that out. I've just used the first 3 examples myself. I thought I saw in a previous post where someone had used the 4th one to run an executable. My mistake. I will edit original post to remove that one. I do know, though, the first three work well. I'm sure each way have their own set parameters and reason for using them in the way they are, but if one is just opening an exe, then one way will work for it. Thanks again m8.