Create .exe which opens a URL

Hi,

I have just recently posted the following topic:

http://www.cplusplus.com/forum/windows/263015/

I am sorry for coming back already.

Basically all i need is a .exe which opens a URL or which sends a HTTP GET request for example www.google.ch.

Duthomhas was so kind to give me the following code:

<code>
#include <windows.h>
#include <shellapi.h>

#pragma comment(lib, "Shell32")

int main()
{
ShellExecuteA( NULL, NULL, "http://www.cplusplus.com", NULL, NULL, SW_SHOWNORMAL );
}
</code>

This works jut fine but needs admin rights to execute the .exe. Is there a way to open a URL without asking the user for elevated privileges? I would like to use C but if it's easier with C++ i would not mind to switch to C++.

Regards and thanks,
Markus


You need admin rights just to run the .exe? That doesn't make sense to me, unless your environment as a whole is restricted.
What happens if you remove the call to ShellExecuteA? Does it still make you be an admin to run the exe?

If the call to ShellExecuteA is failing, what is its return value?
If the return value is 32 or less, the call failed. See: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea

What IDE or compiler are you using?
Are you making a custom manifest file in your project?
Last edited on
Hi Ganado

I found the solution. I named the file update.exe. As soon as i rename it to something which does not contain the name update it does not require admin rights :-)
Sounds strange isn't it, but it seems to be kind of a security feature. You can try it out if you rename any .exe to update.exe. After you rename it it will have this shield symbol in the icon and it will ask for admin privileges. As soon as the file is renamed back it will run the file as normal user.

Regards and thanks
I cannot reproduce that, but glad you got it working.
Topic archived. No new replies allowed.