Solved

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

Posted on 2008-10-30
4
1,715 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Searching a barcode number within a string. 7 27
Convert time stamp to date 2 58
SQL 2012 Instance Problem 3 63
Estimating my database size 7 21
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

730 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