title: Run exe file from stored procedure fails while manually it succeeds
body: <p>I use SQL Server 2008.  Currently I'm working on a stored procedure that has needs (among other things) to print a file.</p>
  
  <p>Problem:  The text file I create in the sp needs to be printed as landscape.  I use a program DOSPrinter.exe which is a universel printer driver that adds a file to the (default) printer cue from commandline.</p>
  
  <p>I use xp_cmdshell to do this.  The xp_cmdshell has sufficient rights I guess.  I use it to perform some file copy actions and after I set the security on the used directories it works perfectly.</p>
  
  <p>I gave the DOSPrinter the same rights, together with the print device.</p>
  
  <p>However, when type the command manually (C:\temp\DOSPrinter "C:\temp\test.txt") in a command window, the file appears in the print cue.
  When I put the same command in a bat file, and call the bat file manually from a cmd window, the file is send to the print cue.</p>
  
  <p>When I try to place the command in a stored procedure:</p>
  
  <pre><code>    SET @bcpCommand = 'C:\temp\DOSPrinter.exe C:\temp\test.txt'
      EXEC master..xp_cmdshell @bcpCommand
  </code></pre>
  
  <p>the file is not send to the print cue.  If I gtry to call the bat file from the sp, again no file in the print cue.  I'm kinda desperate.</p>
  
  <p>Maybe someone can help me give me some ideas on how to proceed?</p>
  
  <p>Thanks,</p>
  
  <p>jan_solo</p>