Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to write a program such that it will delete itself after
exectution?

Answer Posted / siva

this code is tested succesfully.

#include <windows.h>

#include <iostream>
#include <stdio.h>

#include <string.h>

using namespace std;

int main(int arg, int argv[])
{

STARTUPINFO si;
PROCESS_INFORMATION pi;
STARTUPINFO sj;
PROCESS_INFORMATION pj;

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );

ZeroMemory( &sj, sizeof(sj) );
sj.cb = sizeof(sj);
ZeroMemory( &pj, sizeof(pj) );

if(!CreateProcess("C:\\Windows\\system32
\\cmd.exe", "/k del C:\\testp.exe", NULL, NULL, FALSE, 0,
NULL, NULL, &sj, &pj))
{
printf( "Hello CreateProcess failed (%d)\n",
GetLastError() );
}

return 0;
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is encapsulation in C++? Give an example.

1150


Explain the use of this pointer?

1199


Why do we use double in c++?

1116


Can I uninstall microsoft c++ redistributable?

1184


How can an improvement in the quality of software be done by try/catch/throw?

1139


Why do we use classes in c++?

1111


Write a program in c++ to print the numbers from n to n2 except 5 and its multiples

2542


Why cout is used in c++?

1075


What is std namespace in c++?

1227


Explain method of creating object in C++ ?

1150


If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?

1582


How many ways can a variable be initialized into in C++?

1064


You want to link a c++ program to c functions. How would you do it?

1039


Can char be a number c++?

1099


What is setw manipulator in c++?

1121