Reputation: 15016
This existing question on SO is probably exactly what I need, but it wasn't answered. ;)
I hadn't realized this in my initial testing of my WiX installer, but my application doesn't work properly on Windows 7 after it's been installed. Various assemblies need to read/write files in my installation folder, but access is denied at runtime.
If I then run the application as an administrator, it works perfectly. I can also change the properties of the application manually so that it always runs as an administrator. However, I don't want the user to have to click Yes to the UAC prompt every time.
The part I don't get is that if I run my executable from my source code folder, I don't have to run it as an administrator and it works perfectly.
Can anyone explain why: 1. My executable, when run from my bin/Debug folder, doesn't need to be run as an administrator and works? 2. How I can get WiX to install the executable so it works exactly the same way? (i.e. doesn't require right-click + Run as Administrator)
Thanks!
Upvotes: 4
Views: 2158
Reputation: 25583
Programs generally shouldn't be diddling with things in the Program Files folder, but if you do need to do this, you will need to ensure that the permissions on your program's installation folder are set as part of the installation process.
Now that I have berated you for trying to do this, I will give an example from a WiX installer for a program that I maintain that does this same sort of naughty log file writing:
<Directory Id="DirectoryLogs" Name="Logs">
<Component Id="ComponentCreateFolderLogs" Guid="SOME-GUID">
<CreateFolder>
<Permission
GenericAll="yes"
User="Authenticated Users" />
</CreateFolder>
<RemoveFile
Id="RemoveFileLogsAll"
Name="*.*"
On="uninstall" />
</Component>
</Directory>
So the installer will create the Logs
folder, give all Authenticated Users
NTFS permissions to wreak havoc on that directory, and blow away all of the log files that were created after the original installation as part of the uninstall process to leave a clean uninstall.
Is it great design? No--Windows logo requirements freak out about this--but it happens a lot especially in internal environments, so this is how you do it.
Good luck!
Upvotes: 6