prabhu
Posts: 9
Joined: Mon Sep 08, 2014 6:39 am

File cound not be opened. Operating system error code 5

I am trying to insert records in to database by using bulk insert command

The file is in temp folder But I am getting the
File cound not be opened. Operating system error code 5(Access is denied)

I give full Network permissions and Full control to the Temp folder in APPDIR

What else require to access the file.

Please sugges me on this
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: File cound not be opened. Operating system error code 5

Hello,

You can see my reply in the "An object or column name is missing or empty" thread.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prabhu
Posts: 9
Joined: Mon Sep 08, 2014 6:39 am

Re: File cound not be opened. Operating system error code 5

Hi Daniel,
I am working for a client project. It is not possible to share my api file.
I can share my error image. I hope u can help me by look in to this image.
I want to execute a script in the sql server. By taking the AU_complete.txt file from my temp location.
Attachments
ee.png
ee.png (116.12 KiB) Viewed 10079 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: File cound not be opened. Operating system error code 5

Hello,

Please give me some time to test your installation scenario and I'll get back to you as soon as I have a conclusive answer. In the meantime it would be really useful if you could isolate the behavior in a sample (.aip + its referred installation resources) and send it us to support at advancedinstaller dot com so we can investigate it.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: File cound not be opened. Operating system error code 5

Hello,

I've tested the scenario and indeed I was able to replicate the behavior. This error seems to be generated by the default permissions which are added by default at install time to temporary files. As a workaround you can add your "AU_complete.txt" file as a regular file and add Everyone-> Full Control permissions on it. So, can you proceed like this:
1. remove the "AU_complete.txt" temporary file added in "Files and Folders" page
2. add the "AU_complete.txt" as a regular file in "Windows Volume\Temporary" folder from "Files and Folders" page
3. select the added "AU_complete.txt" file, from its context menu choose "Properties..." option and go to "Permissions" tab
4. add Everyone -> Full Control permissions on the "AU_complete.txt" file
5. go to "SQL Script Replacements" tab and edit your script replacement like this:
  • Find what: your file path
    Replace with: [TempFolder]AU_complete.txt
6. rebuild and test again the setup

and see if this helps?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: File cound not be opened. Operating system error code 5

Hello,

Investigating this error further it seems this happens because of the SQL authentication type. When you authenticate using an SQL login, all scripts which are ran under this connection will run under the Windows account which the Sql Server (e.g. SQLEXPRESS) service is logged on as. By default the Sql Server service is logged on as "Network Service" account. Therefore, when you authenticate using an SQL login the script will run under the "Network Service" account (the account which the Sql Server service is logged on as). So, in order to run successfully your script (when authenticating with an SQL login) you should make sure the "Network Service" account has "Read" and "Read & execute" permissions on your "AU_complete.txt" file.

Also, when authenticating with a trusted connection (Windows authentication) the scripts will run under the current logged on Windows user account (when the "Impersonate installing user" option is enabled for your SQL connection added in "SQL Databases" page) or under the "System" Windows account (when the "Impersonate installing user" option is disabled). Therefore, when using a Windows authentication your script should run successfully even when adding the "AU_complete.txt" file as a temporary file because both of the above Windows accounts (current logged on user and "System") has by default access permission on the installed temporary file.

Hopefully this info will be useful for you.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prabhu
Posts: 9
Joined: Mon Sep 08, 2014 6:39 am

Re: File cound not be opened. Operating system error code 5

Thank you Daniel for u r reply.
I will try this way.
U gave me valuable information. I have been searching for the cause. I hope it will sove my problem.
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: File cound not be opened. Operating system error code 5

You're welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”