End process


My intention is that you can not run a certain application (prueba.exe) on a computer with windows. That equipment is usually always on and with my program running, and with the screen locked, so other users can enter. The application checks the processes that are in memory and, if resident, "prueba.exe" kills the process. This works fine when I'm in my session (being an administrator) and I open the program "prueba.exe" and it kills it, it also works fine when I open the program "prueba.exe" from my same session but launching it using runes with another user ( does not have privileges). The problem comes when another user logs in with their unprivileged user (my admin session and my program is still open) and that user runs the so-called "test.exe", so my application does not kill the process, I do not understand why.

In summary, my application kills the process from my session but if another user without admin logs in and runs the "prueba.exe" it allows you to execute it and my application does not kill the process.

I put the code:

#include <stdio.h>
#include <windows.h>

#include <Tlhelp32.h>
#include <psapi.h>

void main(void)
    while (1)
        HANDLE CProc;
        PROCESSENTRY32 process;
        CProc = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
        process.dwSize = sizeof(PROCESSENTRY32); //windows 10
            HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0,(DWORD) process.th32ProcessID);
                printf("prueba.exe in memory");

Thank you very much in advance. (Win7)

asked by Bela 08.11.2018 в 10:24

1 answer


There are several casuistry, my program is active. If in my session (ade admin) abro prueba.exe my program finishes the process prueba.exe and appears code 5 Same case, but launching test.exe with runas.exe (so that it launches it with another user but without admin's permissions) it also ends the process prueba.exe with code 5. The issue is that if I change the session (leaving the admin open with my program observing), and in that other session I open.exe, return to my admin session and do not finish the "test.exe" and share the code 6 I do not know how to interpret those codes, I guess 5 is a good sign because it ends, but on the 6th I have no idea what it means or how I can fix it. Any ideas? Thanks again.

answered by 09.11.2018 в 11:21