Creating an event trigger for a scheduled task on Windows Server 2008 R2

I have a scheduled task that currently runs every night at 3 AM.  I want to add an event trigger that will allow the task to run if a condition is met.

The task copies files with monetary transactions to  specific folders.  I will have a text file that designates whether or not the amounts are in balance.  If the text file value is set to "Y" then the files are to be copied otherwise an email will be sent notifying the recipients of the out of balance condition.

How can I do this?

Thanks

Glen
GPSPOWAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lionel MMSmall Business IT ConsultantCommented:
so you will have two amounts in this text file, somewhere, and if they are the same you want X and if they are not the same you want Y? Can you post the text file so we can see what we need to search for?
GPSPOWAuthor Commented:
Attached is an example of the "csv" file that will be generated.  The column "InBal" has a "N" value.

If this value is "Y" then I want the task to run.  If the value is "N" then I need to send an email reporting the out of balance condition.  I will use the fields within this file:

OPSATB, SPATB etc. as data within the email.

Let me know if you need anything else.

Thanks

Glen
CroweMsg.csv
Lionel MMSmall Business IT ConsultantCommented:
OK this first code shows you how we can get any of the data you want out of the file
@echo on
setlocal EnableDelayedExpansion
for /F "skip=1 tokens=1-13 delims=," %%a in (C:\Temp\CroweMsg.csv) do (
Echo %%a
Echo %%b
Echo %%c
Echo %%d
Echo %%e
Echo %%f
Echo %%g
Echo %%h
Echo %%i
Echo %%j
Echo %%k
Echo %%l
Echo %%m
)
exit /b

Open in new window


and this shows you that we can setup two different scenarios based on whether we get a result for %%m as either Y or N
@echo off
setlocal EnableDelayedExpansion
	for /F "skip=1 tokens=1-13 delims=," %%a in (C:\Temp\CroweMsg.csv) do (
        if "%%m" EQU "N" (
          call :Yes
         ) else (
          call :No
	)
)
exit /b

pause
:No
Echo No
GoTo End

:Yes
Echo Yes
GoTo End

:End
Echo End

Open in new window


With that established all I need from you now is exactly what you want to happen when it is Y (yes) and when it is N (No); like what email sender will you use and what files do you want to have copied and to where (or you can simply add it to the sections provided).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

GPSPOWAuthor Commented:
Here is the batch file that runs if the "InBal"="Y"

net use D:\DTS

copy  D:\DTS\DailyATB\Daily_ATB_Test.txt  "\\pmcfs\groups\Accounting\CHI\DailyATB\rca_p1_mt_daily_accts_"%date:~10,4%%date:~4,2%%date:~7,2%".csv"
copy  D:\DTS\DailyBD\DAILY_ATB_BD_XFR.txt  "\\pmcfs\groups\Accounting\CHI\BadDebtData\rca_p1_mt_bd_transfers_"%date:~10,4%%date:~4,2%%date:~7,2%".csv"

copy  D:\DTS\DailyTXN\DAILY_ATB_TXN_DETAIL.txt  "\\pmcfs\groups\Accounting\CHI\DailyTxnData\rca_p1_mt_daily_txn_"%date:~10,4%%date:~4,2%%date:~7,2%".csv"

copy  D:\DTS\DailyNPA\DAILY_ATB_NPA.txt  "\\pmcfs\groups\Accounting\CHI\DailyNPA\rca_p1_mt_daily_npa_"%date:~10,4%%date:~4,2%%date:~7,2%".csv"

net use D:\DTS /DELETE


If "InBal" ="N" then:

Recipient:  gpspow55@gmail.com
Sender:   gpowers@stlukeshealth.org
Subject:  Daily ATB Files Not In Balance
Message:  "Text lines"  and then list:

"OPS ATB:"    OPSATB value
"SP ATB:"       SPATB value
... all other values.

Thanks

Glen
Lionel MMSmall Business IT ConsultantCommented:
And this work as is--you have tested this batch file (because there seems to be nothing to send the email to me)?
GPSPOWAuthor Commented:
I think I get the gist of what I need to do with the existing batch file I have been using to create files unconditionally.  I will put it in the :yes section and test to see if it will run with the conditions.

Thanks

Glen
Lionel MMSmall Business IT ConsultantCommented:
OK but let me know if you can't get it to work.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.