EDN Admin
Well-known member
Im having a bit of programming issues regarding the ownership of files on the users system. Ill explain the background:
Ive created an application based on .NET 2.0 framework. This application can be run from limited user profile, it does not need any administrative privileges. Now I need to distribute my application. (I will call this as MAINAPP during this thread
discussion). The distribution is done through a custom-made setup program. This Setup application is also built on .NET 2.0 framework. I am not using WindowsInstaller or InstallSheild or any installer for some particular reasons. I have to use the custom-made
Setup, totally made by myself. (I will call this app as SETUP during this discussion)
The MAINAPP files are packed into cabinets, and the SETUP app will unpack them on the end users system. The default directory the SETUP app will create will be within Program Files of the computer.
Now here begins the problem. In Windows Vista and Windows7, you cannot directly create folder inside the Program Files folder and copy files therein. You need to have administrative privileges. It was fine by me, I need to run the SETUP in administrative
mode (UAC) anyway so that it has access to Program Files folder.
A quick search on the internet revealed a very easy way for that. In the SETUP projects "app.manifest" file, you have to change the Level of the program to require the administrator, like this:
originally: <requestedExecutionLevel level="asInvoker" uiAccess="false" /><br/>
change to: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Now whenever the SETUP executable is run, this makes the Windows7/Vista ask the user that this app needs admin privileges, the user says Yes or switches to admin profile and runs from there, or etc etc. Its in the hands of the user to run the SETUP thru
admin ID, its on him how he does it. SETUP will not install until its been given admin access. This is perfectly ok.
When the user goes through my custom-made SETUP, the SETUP unpacks the compressed files (using some decompression code I found on the internet) into the Program Files folder and shows that setup is complete.
Now the problem which has occurred here is that the SETUP, which had admin access, has created files inside Program Files folder. These files automatically have gained Admin ownership because they were created from an administrative privileged software.
I dont want that to happen. I need the unpacked files to have normal privileges. Because these files have admin privileges, it creates problems in executing the MAINAPP. The MAINAPP crashes as soon as it is run (which I have no clue why this is happening).
But when I run MAINAPP as administrator, it runs ok. If I manually open the properties of all the unpacked files of MAINAPP and remove the administrator ownership from them and bring them down to ordinary user level, then my MAINAPP runs ok.
I need to know how to resolve this matter. Either I need to code my SETUP in such a way that it sets the security of all the unpacked files as ordinary user, or I need to change the entire way this thing is working, etc.
Need suggestions from experts!
Thanks in advance!
View the full article
Ive created an application based on .NET 2.0 framework. This application can be run from limited user profile, it does not need any administrative privileges. Now I need to distribute my application. (I will call this as MAINAPP during this thread
discussion). The distribution is done through a custom-made setup program. This Setup application is also built on .NET 2.0 framework. I am not using WindowsInstaller or InstallSheild or any installer for some particular reasons. I have to use the custom-made
Setup, totally made by myself. (I will call this app as SETUP during this discussion)
The MAINAPP files are packed into cabinets, and the SETUP app will unpack them on the end users system. The default directory the SETUP app will create will be within Program Files of the computer.
Now here begins the problem. In Windows Vista and Windows7, you cannot directly create folder inside the Program Files folder and copy files therein. You need to have administrative privileges. It was fine by me, I need to run the SETUP in administrative
mode (UAC) anyway so that it has access to Program Files folder.
A quick search on the internet revealed a very easy way for that. In the SETUP projects "app.manifest" file, you have to change the Level of the program to require the administrator, like this:
originally: <requestedExecutionLevel level="asInvoker" uiAccess="false" /><br/>
change to: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Now whenever the SETUP executable is run, this makes the Windows7/Vista ask the user that this app needs admin privileges, the user says Yes or switches to admin profile and runs from there, or etc etc. Its in the hands of the user to run the SETUP thru
admin ID, its on him how he does it. SETUP will not install until its been given admin access. This is perfectly ok.
When the user goes through my custom-made SETUP, the SETUP unpacks the compressed files (using some decompression code I found on the internet) into the Program Files folder and shows that setup is complete.
Now the problem which has occurred here is that the SETUP, which had admin access, has created files inside Program Files folder. These files automatically have gained Admin ownership because they were created from an administrative privileged software.
I dont want that to happen. I need the unpacked files to have normal privileges. Because these files have admin privileges, it creates problems in executing the MAINAPP. The MAINAPP crashes as soon as it is run (which I have no clue why this is happening).
But when I run MAINAPP as administrator, it runs ok. If I manually open the properties of all the unpacked files of MAINAPP and remove the administrator ownership from them and bring them down to ordinary user level, then my MAINAPP runs ok.
I need to know how to resolve this matter. Either I need to code my SETUP in such a way that it sets the security of all the unpacked files as ordinary user, or I need to change the entire way this thing is working, etc.
Need suggestions from experts!
Thanks in advance!
View the full article