0

I am working on an application that installs some fonts in user windows font directory. but the problem is when the software tries to install the font, windows deny its access and my software show an error like "access to the path c:\windows\fonts\segoeuisl.ttf is denied" to user.

I try many way in stackoverflow and other websites but still my problem is exist and I don't understand why its not working.

so I'm here to ask you how can I solve this problem.

I'm waiting for any suggestion.

Edit 1:

I also use File.Copy method to install fonts.

Edit 2:

I Don't want to ask user to run my software as admin, because after that, user can't drag & drop any file.

I want to access directly from my software. Now I want to ask you HOW CAN I ACCESS TO DENIED DIRECTORY WITH MY OWN SOFTWARE WITHOUT USING ADMIN RIGHT?!!! Thanks

Shahryar
  • 215
  • 1
  • 3
  • 11
  • 1
    This has been answered already here: http://stackoverflow.com/a/14796255/420787 – S.Richmond May 21 '14 at 06:44
  • You can use two ways to install fonts see this links [install fonts with C#][1] [another answer][2] [1]: http://stackoverflow.com/questions/14796162/how-to-install-a-windows-font-using-c-sharp [2]: http://stackoverflow.com/questions/21986744/how-to-install-a-font-programatically-c – FrhdMhrvrz May 21 '14 at 06:45
  • "Tried many ways, please explain/help me to fix it" is not very good explanation of problem you are facing. Please try to be more specific and show what you tried and what does not work. – Alexei Levenkov May 21 '14 at 07:09
  • Why reinvent the wheel? Windows Installer supports installing fonts. PS- It's impossible to get access to restricted areas without admin rights. #Security101 – Christopher Painter May 21 '14 at 11:57
  • OK. Now I know how to solve this problem. Thanks for your help. – Shahryar May 21 '14 at 12:01

1 Answers1

0

It looks like you are trying to simulate an installer. Why not actually use one?

You could take a look at InstallShield. This is a utility that allows you to create an installer which can be used to deploy your fonts.

Another option would be to have the user run your program as administrator. Add the following line to a Manifest file.

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

This will prompt the user every time the program executes, and asks for administratorpermissions.

The second option is not advised and will most likely cause your users to become annoyed by the constant popup of allowing to run as administrator.

Then again, why would you want to simulate an installer when you can have an actual one?

Matthijs
  • 3,162
  • 4
  • 25
  • 46
  • I don't want to set admin right to my software. because after run my software as admin, user cann't drag & drop any file to software. – Shahryar May 21 '14 at 11:50