H
H
Hryhorii Shcherbak2019-06-30 22:42:08
System administration
Hryhorii Shcherbak, 2019-06-30 22:42:08

Why doesn't my batch file end the process?

Hey!
There is a BAT file. Which should monitor the folder for the presence of pdf files in it, if the file appears, it must be printed and deleted.
the problem is that it works with the first file, then Adobe reader does not close completely, a window with a list of recent documents remains, etc.
I tried to add taskkill /f /im AcroRd32.exe but the process hangs on and the printing does not continue accordingly.

@echo off
chcp 866 >nul
set time=5
:loop

for %%i in (*.pdf) do (
"C:\Programme\Adobe\Reader 10.0\Reader\AcroRd32.exe"  /t  "%%i%"  "A3SWEin" "OKX058RM.DLL" "IP_192.168.160.113" 
)

taskkill /f /im AcroRd32.exe
for %%i in (*.pdf) do (
erase *.pdf
)

ping 127.0.0.1 -n %time% >nul
Goto :loop

If the BAT file is restarted, then it closes the Adobe reader, but after printing 1 document, the history repeats.
Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Moolzv Rivers, 2019-06-30
@SaddledSharp

Hello, maybe because you have a loop at the end that teleports all the time to the mark above without stopping?))
PS: goto loop

E
Ezhyg, 2019-07-02
@Ezhyg

To score on all sorts of batch files and use the standard Windows scheduler, since it can run commands and track events. Plus, it kills processes itself if they run longer than such and such a time, etc.

0
0xD34F, 2017-09-08
@eternalfire

Recursion.

function getRecursiveStr($arr) {
  $t = [];

  $keys = array_keys($arr);
  foreach ($keys as $key) {
    if (is_array($arr[$key])) {
      $t[] = $key;
      $t[] = getRecursiveStr($arr[$key]);
    } else {
      $t[] = $arr[$key];
    }
  }

  return implode(', ', $t);
}

$a = [
  "Один" => [
    "Два" => [
      "2.87" => [
        "2.88",
        "2.89"
      ],
      "Три" => [
        "Три с половиной",
        "Четыре"
      ]
    ]
  ]
];

echo getRecursiveStr($a); // выведет "Один, Два, 2.87, 2.88, 2.89, Три, Три с половиной, Четыре"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question