Reputation: 51
I have a VB6 app that manipulates files in ProgramData folder Win7. It does fine with files that it creates but any files that were initially installed, it cannot delete. I feel there may be more issues unless the program can run as administrator.
I have tried putting a TrustInfo section into its manifest but a message appears....'The requested operation requires elevation.'
The manifest includes...
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
Any idea how to give it the required 'elevation' please? After more research it seems correct that ProgramData is the folder to use in Win7, but all the files installed need administer permission to delete (whether the setup.exe is run as or not as Administrator).
Out of interest I compared the Security Properties of a file that was installed, with a file that the App subsequently created. The installed file had SYSTEM and Administrators with full permissions and Users with only Read and Execute. The created file had an extra object, my account, with full permissions. That sounds logical, so I added my account, with full permissions, to one of the installed files, expecting the App to be able to delete it. Then, as expected I can delete the file manually in Explorer with, no permission required. But the app still cannot delete it! So then I changed the Users permissions for the installed file to full permissions, the App still cannot delete it! So then I changed to Owner of the file in Advanced, first to Users, then to my account. Still the app cannot delete it. Now there does not seem to be any difference between the security settings of the installed file and the app created file, both have same permissions and same owner.
So if I compare the Advanced Security settings there are still some differences between to two files. The installed file has 2 extra 'not inherited' entries in permissions for my account and Users. Even if I remove the Users entry in Advanced (which is still only Read access) the app still cannot delete.
I'm left wondering if this a VB6 problem and should I just leave the app in its old install folder where it can do what it likes with its own files!!
Upvotes: 1
Views: 4871
Reputation: 51
This excellent article...by Kenny Kerr has the answer which is to use level="highestAvailable" in the manifest.
Upvotes: 0
Reputation: 1072
After doing some research on your question I found many people were using a manifest much like this. Try setting the level to "asInvoker". :
<?xml version="1.0" encoding="utf-8" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="MyProjectName"
type="win32" />
<description>MyProjectDescription</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Replace "MyProjectName" with your project name.
Upvotes: 1