Smart Recent Blog Post List

Oct 1, 2013

Running bat file from the C++ source code

What to do when one has to execute batch script from the c++ source code ?

System command can solve the purpose in this context.
Here is the syntax details :-

int system(  const char *command );
int _wsystem(   const wchar_t *command );


Example :-
  Suppose if some one want to restart a service named "TestService" form the batch file.
Then c:\\sample.bat file would look like as:-

net stop TestService
net start TestService

calling it from source code:-
    system ("c:\\sample.bat");



For API refrenece
http://msdn.microsoft.com/en-us/library/277bwbdz(v=vs.90).aspx




0 comments:

Post a Comment

Smart Recent Blog Post List