Application throws Exception by running without admin privileges

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • unleashsiva
    New Member
    • Oct 2007
    • 3

    Application throws Exception by running without admin privileges

    Hi,

    I developed an VB.Net application using Microsoft Visual Studio .NET 2003. I created an msi for that application. After installing the msi package, the application runs perfectly with Admin privileges. If i log into some other user account where they dont have admin privileges, it throws the following error.

    An unhandled exception of type 'System.Unautho rizedAccessExce ption' occurred in mscorlib.dll

    Additional information: Access to the path "C:\Program Files\Sasken\Ne tSim\NS.txt" is denied.

    The code i had written is:
    Private userData As FileStream
    userData = New FileStream(Appl ication.Startup Path + "\NS.txt",FileM ode.OpenOrCreat e)

    Please help me to solve this issue.

    Regards,
    Siva.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    The error message is self explanatory.

    The is simple the non-admin user does not have previliges on the file your application is trying to access. You need to change the previliges of your system settings not the application.

    Comment

    • unleashsiva
      New Member
      • Oct 2007
      • 3

      #3
      Priliges of the system settings cannot be modified by the non-
      Admin users. And moreover the NS.txt file will be created when we install that application. So, how to mofify in code so that all users can access that file.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by unleashsiva
        Priliges of the system settings cannot be modified by the non-
        Admin users. And moreover the NS.txt file will be created when we install that application. So, how to mofify in code so that all users can access that file.
        Have a look at the Directory Services namespace and see what it can do for you.

        Comment

        Working...