0

I wrote a powershell script to print out pdf's and send an email to myself. When i run it in powershell from my account it works perfecly. When I convert the script into an exe (using POWERGUI) it still runs fine.

The issue that I have is that when I call that exe from an ssis package ( it runs as an admin account) then the print doesn't work but the email still sends.

My guess is that this occurs because the Print function popsup adobe acrobat and that most likely causes it to not print when ran in the background as another account. Here is my code:

 Try
    { 
      Start-Process -FilePath $UNCpath –Verb Print -WindowStyle Hidden  -PassThru | %{sleep 10;$_} | kill
      Send-MailMessage -To "myaccount@work.com" -From "myaccount@work.com"  -Subject 'printing from script' -SmtpServer "mail.work.com" -Body $path
    return 1
    }
    Catch [system.exception]
    {
     write-host "ERROR: caught a system exception printing"
    }
    return 0
alroc
  • 27,574
  • 6
  • 51
  • 97
Barry DeYoung
  • 43
  • 1
  • 6
  • It's also possible that the account under which SSIS runs either doesn't have access to the printer, doesn't have the default printer set, or doesn't have the printer(s) set up for the account at all. However, you **cannot** depend upon programs that are user-interactive (like Adobe Reader) when using them like this. You will need to find another method that doesn't rely upon launching an application in this way (`start-process`). – alroc Apr 11 '14 at 17:18
  • possible duplicate of [Adobe Reader Command Line Reference](http://stackoverflow.com/questions/619158/adobe-reader-command-line-reference) – alroc Apr 11 '14 at 17:20
  • So if I understand you correctly, even if I use the adobe via command line (calling adobe.exe /p ) there is no way to print without opening the application. – Barry DeYoung Apr 11 '14 at 17:34
  • That may be the case, yes. But that isn't to say that it's impossible to do what you're looking for - just maybe not with Adobe Reader – alroc Apr 11 '14 at 17:51
  • try manually running your script using the same credentials as ssis is using – Jimbo Apr 11 '14 at 20:43

0 Answers0