How do I make a program turn it self on again after it's done?

Nov 21, 2016 at 10:13pm
So I had this crazy idea today that I want to turn on a program again after it finishes it's work or in any other part of its code. I already know that typing system("start notepad.exe); turns on notepad but system("start nameOfMyProgram.exe"); doesn't turn on my program. I get an error. Could anyone help me out with this? :D
Nov 21, 2016 at 10:35pm
That's just what everybody needs; a program that they can't end.
Nov 21, 2016 at 10:41pm
It's for research purposes :D
Nov 26, 2016 at 12:03pm
When you use the start command, you have to specify the directory your file is in. Typing start notepad.exe works because the path environment variable for notepad.exe is already set.

So do this:

std::system("start C:\\Path...\\name.exe")
Last edited on Nov 26, 2016 at 12:04pm
Nov 26, 2016 at 12:09pm
You could use this for dangerous purposes though...

On Windows computers:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdlib>

class largeType
{
    private:
      long long int x[100][100];
    public:
      largeType() { }
};

int main()
{
    std::system("start name.exe");
    std::system("start name.exe");

    while (true)
    {
        largeType *p = new largeType;
    }

    return 0;
}

Open this and your computer is done. Only if you open it though. Doesn't do any permanent harm. Just have to reboot.
Last edited on Nov 26, 2016 at 12:12pm
Topic archived. No new replies allowed.