Working on a helper windows process in Win7 with VC++ 10.0. I want the service to start a process if it's not started, but both CreateProcess() and ShellExecute() fail. I thought, it's fine as long as I could create a startup entry in the registry, but no luck. I know it works because the line right before it begins the registry line, creates a file called 'hello.txt' in C:, and it does.
Is there a reason it cannot execute or create processes, or write to the registry (HKLM)? I'm an admin so i don't think it's a priviledge thing.
If it is so, then you cannot launch child processes in interactive desktop. There is a way by "stealing" autentication token from a process that already runs there (explorer.exe for example or winlogon.exe if you want administrator rights without UAC intervention) and then spawn the child process as usual using CreateProcessAsUser().
So Modoran, how would I use that technique using CreateProcessAsUser() to spawn a process? Would I just use the admin user or what? I don't want users to have to change a bunch of settings to get it to work.
I just need a helper service. I'm going to have the service check periodically to see if a process is running, for example, test.exe. If test.exe is not in the list of running process, it creates the process again. That's all I need it to do.
EDIT: Hell yea I think I got it, I just used the function from the code you sent me. Well, I got it open a process finally (notepad.exe).
Question for you, should the service be able to check if a process is running or not? I haven't implemented the code yet, but right now there's no communication between the processes, which I don't really need, like I said above.