Hi, all,
I am using a command line program called blat to send emails and I have confirmed this portion is working without an issue.
I then wrote another batch script to find a task running in the task manager using the tasklist command. I can write this information out to a file without issue.
My problem is that no matter what I do, the blat script (dos) will not send anything for me. I have even gone as far as writing the error level out to a file to see what the value is when the application being checked is running and not running.
When the application to check is running, the error level being written out is zero. When the application to check is not running, the error level being written out is one.
This is what I have... any ideas as to where I am going wrong?
Also, as a side note, the text file is not even deleted, so looks like the script doesn't even get that far!
Code:
@ECHO OFF & SETLOCAL ENABLEDELAYEDEXPANSION
::Install blat in the registry each time this program runs otherwise it will not send out the notification email.
\\vdifiles\blat$\blat.exe -install mailserver.mydomain.com alerts@mydomain.com
::Lets see if the executable is in the Task Manager, Processes tab.
::Write this check out to a file.
TASKLIST /FI "STATUS EQ running" /FI "IMAGENAME EQ nsoftware.AS2Connector.exe" /FI "USERNAME EQ c$yp1504" /FO LIST >> RunningTasks.txt
::Let's check the RunningTasks.txt file to see if nsoftware.AS2Connector.exe is contained within.
FINDSTR "nsoftware.AS2Connector.exe" < RunningTasks.txt
IF %ERRORLEVEL% = 0 CALL blat-found
IF %ERRORLEVEL% = 1 CALL blat-notfound
::Do some cleanup.
DEL RunningTasks.txt /S /F
ENDLOCAL
When the process is found and then written out to the file, it shows like the screen shot attached. Please advise. Thanks.
Bookmarks