I am using regular C++, not Visual C++. I need to run an exe as admin from my C++ application. The C++ application cannot have a manifest that makes it run as admin because I am using it as a "middle man" for a Java application. When I run the code below it sits with a wait cursor for 45 seconds or so and then nothing. No error, no warning, doesn't launch the exe, nothing. I looked at it in task manager and it shows up for 45 seconds and then disappears. Why is it not doing anything and how can I make it work?
Also, I am using MingW compiler & Code::Blocks if that is any help...
I think no one has tried to help because you are directly contradicting yourself and it looks like you don't even have a question formed yet. By first saying "... an exe that MUST be run as admin." then in the next sentence "However I need it to not require admin, ...".
I'll give you the benefit of the doubt and ask you to reword your request. What are you trying to do? Don't be vague.
Your PathRemoveFile() function is incorrect, you are returning a vector allocated on the stack, which can be freed at any time. Use new opoerator if you want to do that. Windows already has PathRemoveFileSpec() from shlwapi.dll which do exactly the same thing.
If the child process does show up in task manager for 45 seconds, then there is nothing wrong with your code, the process is created and running. Maybe there is a problem with 3rd party application, try renaming it from "uac.exe" into something else.
Does right-click and choose "run as administrator" works for 3rd party application directly from windows explorer ?
1. I tried that PathRemoveFileSpec() and it said something like it was called in the wrong scope.
2. The child process does not show up, the parent process shows for 45 seconds.
3. The application I am trying to run has a manifest that forces admin.
4. I found that code for the function somewhere, I don't remember where, on the internet.
It wasn't wrong scope, here is the error
C:\Users\Timberwolf\Documents\C++ Projects\Tool Belt UAC Launcher\main.cpp|7|undefined reference to `_imp__PathRemoveFileSpecA@4'|
I want to find the folder the exe is in (ie Program: "M:\TOOLS\WIN\IOBIT\app.exe" and I want this: "M:\TOOLS\WIN\IOBIT"). Basically I want to launch uac.exe and it is in the same path as app.exe (this is the C++ app).
So I have:
"M:\TOOLS\WIN\IOBIT\app.exe" and "M:\TOOLS\WIN\IOBIT\uac.exe"
I want to run:
"M:\TOOLS\WIN\IOBIT\uac.exe" from "M:\TOOLS\WIN\IOBIT\app.exe" as Admin in Windows 7 and Vista.