Results 1 to 13 of 13
  1. #1
    New Lounger
    Join Date
    Jan 2010
    Location
    Puyallup, WA
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts

    File Access Denied

    I have a VB.Net application that installs in the Program Files (x86)\application name\bin folder. The bin folder also contains a static data file that is permitted as read only. The application runs perfectly in development where the bin folder is located in the VS\projects\application name\bin folder. However when the deployed application is run, it throws the error "access to path denied". This is the path to the folder in which the application resides. I am at a loss to understand why access is denied to a file in the folder containing the application. Any help would be appreciated.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Fritzsche,

    You don't mention the version of windows in use, I'll assume W10.

    In development are you using an Admin Account?

    Is the machine/account running the program, when Access is Denied, running as a "Standard User"

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    New Lounger
    Join Date
    Jan 2010
    Location
    Puyallup, WA
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by RetiredGeek View Post
    Fritzsche,

    You don't mention the version of windows in use, I'll assume W10.

    In development are you using an Admin Account?

    Is the machine/account running the program, when Access is Denied, running as a "Standard User"

    HTH
    This happens running Win 10 or 8.1 using a standard account running as a standard user.

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Fritzche,

    If the program is installed in Program Files or Program Files (x86) Standard Users are barred from writing to these locations, e.g. installing software.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #5
    New Lounger
    Join Date
    Jan 2010
    Location
    Puyallup, WA
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by RetiredGeek View Post
    Fritzche,

    If the program is installed in Program Files or Program Files (x86) Standard Users are barred from writing to these locations, e.g. installing software.

    HTH
    The application does not write to the file. It reads data from the file. The contents of the file is never changed. That is what has me puzzled. It is my understanding that you can read a file as a standard user.

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Fritzsche,

    Could you post a screen shot of the Security tab for the file after selecting the appropriate user in the Group or user names: box on one of the machines/userids with the problem?

    Example:
    FileSecurity.PNG

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. #7
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,202
    Thanks
    49
    Thanked 987 Times in 917 Posts
    It's possible your program is attempting to open the file read/write and therefore you get access denied.

    cheers, Paul

  8. #8
    New Lounger
    Join Date
    Jan 2010
    Location
    Puyallup, WA
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Security.PNG
    Quote Originally Posted by RetiredGeek View Post
    Fritzsche,

    Could you post a screen shot of the Security tab for the file after selecting the appropriate user in the Group or user names: box on one of the machines/userids with the problem?

    Example:
    FileSecurity.PNG

    HTH
    I have attached the screen shot. I hope it came through.
    Security.PNG

  9. #9
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,202
    Thanks
    49
    Thanked 987 Times in 917 Posts
    Process Monitor will track file access requests and show you what's happening.

    cheers, Paul

  10. #10
    New Lounger
    Join Date
    Jan 2010
    Location
    Puyallup, WA
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Paul T View Post
    Process Monitor will track file access requests and show you what's happening.

    cheers, Paul

    Interesting tool. Here is what it shows me.

    ProcessMonitor Shot.PNG

    The code opens the file SitRpt.dta as a random file and then opens another file for output, ReportK. It sets SitRpt.dat to the first record by a seek statement and then gets the first record and prints the record to the text file ReportK. It continues doing this for a few records and then moves to a different location via a seek statement to move more text from SitRpt.dat to ReportK. This does not seem to be what the Process Monitor is reporting as it shows opening SitRpt.dta twice and closing it if that is what CreateFile means. It then attempts to open it a third time and throws the error. I must not be interpreting this correctly. And it does not copy enough records to even think about advancing to a different position in the file.

    Dave
    Last edited by Fritzsche; 2016-05-11 at 18:47. Reason: Tried unsuccessfully to paste the image.

  11. #11
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,202
    Thanks
    49
    Thanked 987 Times in 917 Posts
    The image shows an attempt to create the file with "generic read/write" and this fails. Can you change your code to open the file, read it's contents into memory and then close the file?

    p.s. the dangers of developing with full rights cannot be overstated. I have had many problems installing badly behaved software on corporate networks where we limit user access.

    cheers, Paul

  12. #12
    New Lounger
    Join Date
    Jan 2010
    Location
    Puyallup, WA
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    The file contains a series of text messages. The specific message read depended upon the users response and was located using the seek statement. It appears that moving around the file using the seek statement is treated as a write activity and thus throws the error. I finally decided to convert the file into a series of text files from which a user can choose. The text file is read successfully. Thanks for helping me understand what was going on. I am still not sure why moving with a seek statement is considered a write activity, but the problem is solved by moving to text files.

    Dave

  13. #13
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,202
    Thanks
    49
    Thanked 987 Times in 917 Posts
    Glad you sorted it out.

    cheers, Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •