Last week I got a PM from another user:
As you said in one of the responses, it seems to call svchost.exe and immediately closes. I've tinkered around with it for awhile but I can't seem to make heads or tails of the code. Which line of the code must I edit to get it to open up my program with elevated privileges after entering my credentials?
Here is the link:
After replying to him with my idea of what was happening I haven't hear from him again, so I guess he solved his problem.
Anyway, and I noticed this when I was debugging that program, running the program from the IDE is not always the same than running it as standalone. There must be more, but 3 side effects that I know of are these:
1. Your program delays at the beginning and runs slower.
2. It uses more memory.
3. Some programs won't run on it.
This is mostly gess work, but I believe this is how it happens:
When you run your program from the visual studio environment, you are actually running vshost.exe that is the integrated environment debugger, or connected to it, and your program runs as a or argument parameter of it. If you check your \Bin\Debug folder you will see these files myProgram.vshost.exe, myProgram.vshost.manifest.
myProgram.vshost.exe can not be deleted when you have Visual Studio running. This is the actual program running when you debug. If it is successful it will produce myProgram.exe.
My program was an editor for the host file on "C:\Windows\System32\drivers\etc" that is a system folder. It would start and then you would elevate it privileges and it would try to run another instance of itself, and if successful, the first instance was killed, so you second instance could edit and write to the system folder. Probably you wouldn't see even a flicker when one is starting and the other stopping.
Running it standalone was ok, but in the environment it would just exit after getting the credentials. What was happenning was that it was starting another instance of vshost.exe that was running empty and exiting. So the program would compile, but not do what it was supossed to do. I guess this is an odd situation that most programs wont confront. But mine did.
Please comment on this.