This batch file is generally invoked like this:
D:\killMSAccessWithRunITK.bat d:\data\test.txt ITK_NetworkGeneralUtilities.mdb RunTRPrimaryWebExportOnly
REM @echo off
REM =======================================================================
REM File Name: killMSAccessWithRunITK.bat
REM Date: July 01, 2008
REM Author: Jim Bucks
REM
REM Requires: Resource Kit Utilities kill.exe and tlist.exe put
REM into a directory in the path.
REM %SYSTEMROOT% would be a good choice.
REM Freeware blat program, also installed in the %SYSTEMROOT%
REM
REM Required command line inputs (positional sensitive) you must pass in on the command line
REM
REM The first parameter,
REM is the "log file" location and name
REM The second parameter,
REM is the name of the MS Access code file name
REM current ones are either WebExportUtility.mdb or ITKNetworkUtilities.mdb
REM The third parameter,
REM is the name of the entrance point within the Access code file
REM there are many of these, and they can differ within each Access code file.
REM
REM Here is an example invocation of the command line to be used.
REM killMSAccess.bat d:\data\test.txt WebExportUtility.mdb AutoFileExport2nd
REM
REM
REM Intent: This batch file is to support the hourly Web Export for
REM Doug's InTheKnow utils.
REM The first check is to see if a MSACCESS.EXE is already
REM running. If so, kill it.
REM The risk here is that if a valid MSACCESS.EXE
REM process running, it will be killed.
REM
REM Notes: This version of the file is for Windows Server 2003 only
REM
REM Updated this specific file to run on Windows Server 2003.
REM The old kill.exe will not run on W2k3 - use taskkill.exe
REM The old tlist.exe will not run on w2k3 - use tasklist.exe
REM No longer need to use tlist / tasklist - can call the process
REM name directly from taskkill.exe.
REM
REM
REM It'll kill any running msaccess processes, then invoke
REM the desired ITK process.
REM
REM
REM ******************************************************
set out_file_name=%1
set itk_flavor=%2
set itk_command=%3
set email_addresses="number2@xxx.com,
number2@yyy.com,
number3@yyy.com, number4@zzz.net"
set email_subject="ITK01 taskkill has been run. Running MS Access processes were killed"
tasklist.exe | FIND /i "msaccess.exe" > %out_file_name%
taskkill.exe /F /IM msaccess.exe
REM ******************************************************
REM Check if found any running - hung msaccess processes and email if any were found.
REM A zero length file means no ms access processes were found running.
REM A greater than zero length file means something was found - and an email is sent out via blat as an alert to do some checking.
REM ******************************************************
if %~z1 GTR 0 (
blat %out_file_name% -to %email_addresses% -subject %email_subject%
)
REM ******************************************************
REM Housekeeping to make sure there are no leftovers that might cause problems.
REM ******************************************************
del %out_file_name%
REM ******************************************************
REM Now let's kill any stray "lock" files - WebExportUtility.ldb
REM ******************************************************
del "c:\Program Files\inTheknow\WebExportUtility.ldb"
REM ******************************************************
REM This is the command line from Doug's hourly scheduled web export task.
REM Uses the 2nd & 3rd passed in parameters from the command line.
REM sample command line: killMSAccessWithRunITK.bat d:\data\test.txt WebExportUtility.mdb AutoFileExport2nd
REM ******************************************************
"D:\apps\Microsoft Office\OFFICE11\MSACCESS.EXE" "c:\Program Files\InTheKnow\%itk_flavor%" /wrkgrp "C:\Program Files\InTheKnow\MMT_ITK.mdw" /user "blech" /pwd "blah" /cmd %itk_command%
REM pause
cls
exit