Skip to content

Instantly share code, notes, and snippets.

@iamazeem
Created April 19, 2019 06:08
Show Gist options
  • Save iamazeem/3d0a102c2cdb3530a186042ebf63b7aa to your computer and use it in GitHub Desktop.
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)
// 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