rem Info zur Version:
rem Datum        Wer     Info
rem 24.03.2010   J.Fes   ueberarbeitet
@setlocal
  set ExeToRun_N=%~1
  if "%ExeToRun_N%"=="" goto :PrintUsage
  rem set ExeToRun_N="Notepad"

  set Log_DPNE=nul
  if not "%~2"=="" set Log_DPNE=%~2
  if not "%~2"=="" set Log_DPNE="%Log_DPNE%"

  rem feststellen ob ExeToRun_N bereits gestartet wurde
  tasklist /FI "IMAGENAME eq %ExeToRun_N%*" 2>nul|findstr /i /c:"%ExeToRun_N%" >nul 2>nul
  set ProgIsRunning=%errorlevel%

  rem wenn Prog is running dann diesen beenden
  if "%ProgIsRunning%"=="0" (
      if exist %Log_DPNE% Echo --------------------------------------------------------------------->>%Log_DPNE%
      Echo Stopping...: %ExeToRun_N%>>%Log_DPNE%
      Echo Date TIme..: %Date% %time%>>%Log_DPNE%
      Echo On.........: \\%ComputerName%>>%Log_DPNE%
      taskkill /T /F /FI "IMAGENAME eq %ExeToRun_N%*" >>%Log_DPNE% 2>nul
  )
  
  Goto :MyEnd
  
  :PrintUsage
   Echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   Echo Help:%0
   Echo.
   Echo P1 = Name of Program to Stop
   Echo P1 = DPNE Name of Logfile (Info if file exist log info be appendet to logfile)
   Echo.
   Echo Example: Kill's Execution of Program with name Notepad
   Echo Call ProgKill.cmd "Notepad"
   Echo.
   Echo Example: Kill's Execution of Program with name Notepad  and info will be add to given Logfile
   Echo Call ProgKill.cmd "Notepad" "C:\Temp\Exe_Kill_LOG.txt"
   Echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   Goto :MyEnd
  
  :MyEnd
@endlocal

