Created
April 19, 2019 06:08
-
-
Save iamazeem/3d0a102c2cdb3530a186042ebf63b7aa to your computer and use it in GitHub Desktop.
Qt: Run self-deleting .BAT file using QProcess (https://stackoverflow.com/a/51742823/7670262)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/51742823/7670262 | |
#include <QProcess> | |
int main() | |
{ | |
QProcess process; | |
process.setProgram( "cmd.exe" ); | |
process.setArguments( { "/C", R"(E:\deleteme.bat)" } ); | |
process.setWorkingDirectory( R"(E:\)" ); | |
process.setStandardOutputFile( QProcess::nullDevice() ); | |
process.setStandardErrorFile( QProcess::nullDevice() ); | |
process.startDetached(); | |
return 0; | |
} | |
/* | |
deleteme.bat | |
DEL "%~f0" | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment