executing a bat file from SSIS
I have a bat file that can only be executed successfully from an administrator command prompt. Double clicking on the bat file will return an "Access denied" message and right clicking and running it as an administrator will just fail. I am trying to execute this bat file from an SSIS package using the Execute Process Task, but getting the "Access Denied" message. Please let me know how to get around this problem. Thanks!
May 27th, 2012 10:17am

I would use a proxy account that has the necessary admin rights, and your account and/or the account you are trying to run the bat file with does not have that either. Some how to: Create a Microsoft Windows user account that meets the security context requirement for the package.Create a credential in an instance of SQL Server. Note A credential is a record that contains the authentication information. The authentication information is needed to connect to a resource that is outside SQL Server.Create a SQL Server Agent proxy in the instance of SQL Server. When you create the SQL Server Agent proxy, perform the following operations for the SQL Server Agent proxy in the New Proxy Account dialog box: In the Credential name box, click the credential that you created in step 2.Under Active to the following subsystems, click to select the SQL Server Integration Services Package check box. Note SQL Server Agent proxies define the security context for a job step. SQL Server Agent proxies use credentials to store information about Windows user accounts. The user who is specified in the credential must have the "Log on as a batch job" permission on the computer that is running SQL Server 2005. You can grant the "Log on as a batch job" permission to a user in the Local Group Policy Editor.Create a SQL Server Agent job step that runs the package. When you create the job step, click the SQL Server Agent proxy that you created in step 3 for the job step in the Run as list in the New Job Step dialog box. After you schedule the package, SQL Server Agent may not run the package as a job step successfully. However, if you run this package outside SQL Server Agent, the package can complete successfully. If this problem occurs, click the following article number to view the article in the Microsoft Knowledge Base to troubleshoot the problem: 918760 (http://support.microsoft.com/kb/918760/ ) An SSIS package does not run when you call the SSIS package from a SQL Server Agent job stepArthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 27th, 2012 7:41pm

Thank you Arthur for the detailed solution, before I tried your suggestion, I wanted to let you know that the user account I am currently using is a local admin member and the bat file is local in the SQL server. Would that make a difference? Do you still think I should try your suggestion?
May 28th, 2012 9:46am

Arthur, also I am actually getting the access denied when running the task from visual studio locally on the server and I am logged in with a domain user account member of the local admin group.
Free Windows Admin Tool Kit Click here and download it now
May 28th, 2012 10:54am

What does your .BAT do? On what folder is it stored? Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu
May 28th, 2012 11:32am

Sebastian, the .bat file converts some txt files to xml files. It is located in a directory within the SQL server and both the txt files and the xml files are located locally in the SQL server.
Free Windows Admin Tool Kit Click here and download it now
May 28th, 2012 11:39am

Arthur, also I am actually getting the access denied when running the task from visual studio locally on the server and I am logged in with a domain user account member of the local admin group. Check the permissions - that is. If you have sufficient right is the objective. I guess you do not.Arthur My Blog
May 28th, 2012 11:40am

Hi, Your BAT is stored somewhere in C:\Program Files or C:\Program Files (X86), that's why it requires elevated privileges to execute (even if you're an administrator). Try moving your .BAT (and your files) to a "regular" folder like c:\filetransfers and you won't be asked for elevated privileges.Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu
Free Windows Admin Tool Kit Click here and download it now
May 28th, 2012 11:53am

Sebastian, the .bat file is in a regular folder d:\folder1\folder2\file.bat
May 28th, 2012 12:14pm

Arthur, I am logged in as an administrator on the server, not sure what other priveleges I need???
Free Windows Admin Tool Kit Click here and download it now
May 28th, 2012 12:15pm

Take ownership over the d:\folder1 directory and then retry. This is how you take the ownership: Open Windows Explorer, and then locate the folder you want to take ownership of. Right-click the file or folder, click Properties, and then click the Security tab. Click Advanced, and then click the Owner tab. Click Edit, and then do one of the following: To change the owner to a user or group that is not listed, click Other users and groups and, in Enter the object name to select (examples), type the name of the user or group, and then click OK. To change the owner to a user or group that is listed, in the Change owner to box, click the new owner. (Optional) To change the owner of all subcontainers and objects within the tree, select the Replace owner on subcontainers and objects check box. Arthur My Blog
May 28th, 2012 1:06pm

Arthur, I took ownership and of the entire directory and I am still getting access denied when executing the task in Visual Studio.
Free Windows Admin Tool Kit Click here and download it now
May 28th, 2012 4:40pm

It is possible that you have a Local Policy applied that prevents users from launching scripts. Check this. Arthur My Blog
May 28th, 2012 4:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics