Why it repeats "start" command ?

Helper code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#inclu...
DWORD conmain;
...

void wait_helper(int second)
{
    for(int x = 0; x < second; x++)
    {
        conmain = FindProcessId("Defender.exe");
        if(IsProcessRunning(conhelper) == true)
            std::cout << "ex..";
        else
            system("start Defender.exe");
        Sleep(500);
//---------------------- Half-second ----------------------------------
        conmain = FindProcessId("Defender.exe");
        if(IsProcessRunning(conhelper) == true)
            std::cout << "ex..";
        else
            system("start Defender.exe");
        Sleep(500);
//---------------------- second ---------------------------------------
    }
}

int main()
{
    while(true)
    {
        wait_helper(1);
    }
    exit(1);
    return 0;
}


Defender.exe run 2x.
Can you help me ?
Last edited on
1
2
3
4
5
6
7
BOOL IsProcessRunning(DWORD pid)
{
    HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
    DWORD ret = WaitForSingleObject(process, 0);
    CloseHandle(process);
    return ret == WAIT_TIMEOUT;
}
I showed absolutely nothing about 5 min.
Where do you get your conhelper?
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void wait_helper(int second)
{
    for(int x = 0; x < second; x++)
    {
        conmain = FindProcessId("Defender.exe");
        if(IsProcessRunning(conhelper) == true)
            std::cout << "ex..";
        else
            system("start Defender.exe");
        Sleep(500);
//---------------------- Half-second ----------------------------------
        conmain = FindProcessId("Defender.exe");
        if(IsProcessRunning(conhelper) == true)
            std::cout << "ex..";
        else
            system("start Defender.exe");
        Sleep(500);
//---------------------- second ---------------------------------------
    }
}


Thank you there was a mistake.
Topic archived. No new replies allowed.