gendev said:
I expect that the individual user would choose to run a program as an administrator rathger than a normal user.
I already told you that that doesn't help.
The deal with administzrative permissions since Vista is, it's not eniough to be Admin.
You can embed a manifest with an essential information, that an EXE require administrative elevation, that's described, for example, here:
I think there's a whitepaper or blog post fromn Rick Strahl that describes this for the special usecase of easily embedding a changed manifest. What I remember is that having a file your.exe.manifest within the soma folder as the PJX and side to side by the EXE that's generated by a build, this manifest is embedded into the final EXE without needing tools like mt.exe to postprocess an EXE.
The normal manifest embedded into a VFP9 built excecutable is this:
Code:
<?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"
type="win32"
name="Microsoft.VisualFoxPro"
processorArchitecture="x86"
/>
<description>Visual FoxPro</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
language="*"
processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"
/>
</dependentAssembly>
</dependency>
</assembly>
And what you need to enforce an EXE to run elevated is a changed manifest in the security section:
Code:
<?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"
type="win32"
name="Microsoft.VisualFoxPro"
processorArchitecture="x86"
/>
<description>Visual FoxPro</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
[highlight #FCE94F] <security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator"
uiAccess="false" />
</requestedPrivileges>
</security>[/highlight]
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
language="*"
processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"
/>
</dependentAssembly>
</dependency>
</assembly>
Either that, or you create a shortcut to the EXE that runs it "as Adminsitrator", which means an elevation dialog will appear at the start.
Notice: This will not automatically give the process with that manifest an elevated status, the requireAdin means Windows will ask the user to allow this, if he's a user of the administrative group or show a login, with which a user could switch the invoker of the EXE to be an adminstrative user, which also requires the password for that administrative user, so the minfest is not elvation in itself or a free ticket. I don't know from the top of my head if the EXE would run anyway, without elevation and with all limits that has or whether it would then not start at all.
But to get to the essntial point of the reason such manifest and their security tags were introduced: An admin is not running anything as an admin anymore, that's a changed security concept since Vista. If you don't believe me, than I can't help you. Let me see if I can find it explained in mopre detail and officially from MS:
Hm, well, this is the link I posted earlier, already. I don't know why you ignore so much that's already told to you. I think you can't believe it since you know otherwise. Yes, it was otherwise before Vista, but not since Vista, and Vista was released 2006.
You have configured your UAC setting to "never ask", so you're suppressing some things, but you can't expect anybody to have your setting. And your setting also doesn't make the admin exyperience 100% as it was befrope Vista, you just don't realize when you're elevated and likewise when not.
You should always program in a way a normal user can use your application, otherwise you're undermining the security of the users system. So I explicitly tell this here: While I show how you can embed a manifest that will make it easy for adminstrative users, this should only be foreseen within executables that have an adminstrative nature, not for a normal application. You can set permissions on just the one INI and its folder and thereby also act in foreign territory of TMG, but limit your intrusion into the security decisions of a user or MS to an acceptable level. So I'd still recommend that.
In short: I wouldn't use an application that asks me to elevate it at the start, other than a setup I verify by signature or at least checksum to be a trustworthy unmanipulated setup. Other things like sysinternal tools or other adminstrative tools, but not a normal application. Get it done in a way a normal user can use your application.
Chriss