Solved

How do I run a xp_cmdshell  batch file as a different user?

Posted on 2008-10-30
4
1,665 Views
Last Modified: 2008-11-27
I have a stored procedure that runa a batch file. The batchfile uses GPG to decrypt a file.  When run the batch file from Explorer everything works. The keys for the decryption are installed under another user account that requires a password.  However when I execute the stored procedure the batch file does not work.  I am assuming that SQL SERVER executes the stored procedure as a sysadmin account therefore not allowing the batch file to execute properly.  How can I accomplish getting this to work.

      SET @cmdSql = ' EXEC xp_cmdshell C:\Batch\Decrypt_EmailCleansingList.bat'      
      EXEC sp_executesql @cmdSql

       gpg --batch --decrypt-files C:\RawData\*.pgp
      
0
Comment
Question by:klyles95
4 Comments
 
LVL 4

Accepted Solution

by:
randy_knight earned 63 total points
ID: 22843636
xp_cmdshell runs in the security context of the service account SQL Server is running under.  I'm not aware of a way to change this.  Do you have to run this from a proc?  Can you run the batch file from a SQL Server Agent job?  That will run under the security context of the job owner.
0
 
LVL 6

Assisted Solution

by:bcsql
bcsql earned 62 total points
ID: 22845497
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question