Terminating program

I have this very basic code that launches a .jar file. After the file is launched, the console window stays open and I was wondering if there is any way to auto-kill it? Heres the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;


int main() 
{

cout<<"Launching..."<<endl;
system("\"C:\\Users\\toby\\Desktop\\mineshaft.jar\"");

return 0;
}


Thanks!
The system function is a horrible kludge. Sounds to me like what you want to do is start a whole new independent process to run your jar file, which will let your program above finish without having to wait for the system call to return (which only happens when whatever program it did finishes).

Your OS API provides far better ways to do this than the kludge that is system.

http://msdn.microsoft.com/en-us/library/ms682512(VS.85).aspx
I know system anything is horrible but I just wanted to write a simple program to launch a file and it works. I just want to know how to auto-kill it now. But thank you for the documentation!
If you executed the system call in a new thread, you could then have your main thread kill that thread.
How would I go about doing that? Sorry, I've never really worked with threads before.
Topic archived. No new replies allowed.