I wrote blew code in C++:
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
ofstream sf;
sf.open("script_temp_file_id_b01.py", ios::out);
system("attrib script_temp_file_id_b01.py +h +s +a");
sf << "name = input(\"Enter your name: \")\n";
sf << "print(\"Hello\", name)";
sf.close();
system("script_temp_file_id_b01.py");
system("attrib script_temp_file_id_b01.py -h -s -a");
system("del script_temp_file_id_b01.py");
return 0;
}
this program opens a file and writes the blew python code in it:
name = input("Enter your name: ")
print("Hello", name)
then runs it.
when program runs this code:
system("script_temp_file_id_b01.py");
the script will be executed.
But if user close the program during script executing the two following lines will not execute and the script file will not delete:
system("attrib script_temp_file_id_b01.py -h -s -a");
system("del script_temp_file_id_b01.py");
How can I do this?