you probably shouldn't post site admin login information to your server on the forum/internet.
Google Try & Catch PowerShell, should be plenty examples. Here is one PowerShell Tutorial – Try Catch Finally and error handling in PowerShell that can do error handling within PowerShell.
Thank you very much Russell, changed login )-:
No problem and you should be able to use Try - Catch with ErrorAction (and IF statements) to do any error handling you might need. If you are calling multiple powershell files in one script, you might need to add the Error handling in all the scripts to catch any errors you might have.
I's a different, probably I didn't explain it right.
I don't want to call PowerShell if here any any errors after execution tab commands.
If there are any errors before tabcmd logout I can't catch them later.
Thank you for your support.
I was thinking your batch file was in powershell, or being called from another script. There is no try-catch handling in batch files, you have to use ErrorLevel. I don't write many batch files anymore, I prefer doing command line scripts in powershell. You can pretty much wrap any piece of code in try-catch error handling.
The problem is that tabcmd doesn’t handle error, even if I use errorlevel after tabcmd logout it shows errorlevel=0 regardless of the real error code.
Why don't you use powershell to check to see if the PDF exist?
So I would do a check to delete any current versions of the PDF in the directory you are exporting to, then use Tableau to export, and even though you can't use errorlevel with the tabcmd you can use the output as the indicator if it succeeded or not (so if the tabcmd export piece fails, no PDF should exist). Then by checking for the PDF you can either stop the process, or continue by sending an email with the PDF.
You could use BLAT emailer (www.blat.net) to send emails is open source and rock solid. You could search the forum for blat keyword and read the posts.