Is absolutely wrong and very bad advice. I gave the correct answer above and many years ago (2016).
740 can only be caused by a missing or malformed manifest. All that is explained above,
Simply study how manifest resources work. No need for administrator rights.
so:
- A proper manifest file or resource (asInVoker, unless the application needs access to other user accounts, then and only then requireAdministrator - which is restricted to the application, not the user!)
- Optionally a firewall rule, usually unlikely. when asInvoker applies.
Additional remarks:
During debugging your own code you might use administrator rights, but not for distribution.
Depending on the application, it may be the case that the application is so intrusive or exposed it needs to be code signed.
The latter is unlikely in most normal cases.
And a very belated post script to cpicanco: That is indeed the same manifest file, but you already knew that!
Usually this example manifest is enough:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="MyApp"
type="win32"
/>
<description>My App</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
You may want to set uiAccess to true if applicable, usually not, along with the application name and the platform in the correct places.
Adapt an existing manifest file to include all of the application description part or simply replace or add the trust info part.
If your application has no manifest yet, the above should work immediately.
Simplest way to test: save the above as <your executable name>.manifest in the same directory as your executable.
If it works, compile it into a resource file and include the rc in your application. The resource constant is 24.
Note manifests are case sensitive, be aware of that.
A useful msdn entry is here:
https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests?redirectedfrom=MSDN