0

Whenever i try to kill the ngrok.exe task (start /B "ngrok" call ngrok.exe tcp 22 -log=stdout > ngrok.log) with taskkill (taskkill /IM ngrok.exe /F) it doesn't work. Apparently i kill the ngrok.exe process but Windows Command Prompt (session handler) is still there.

When I try to run the exe again it says: The process cannot access the file because it is being used by another process.


I've also tried to add /T to taskkill and get rid of any child processes, but it doesn't work too. Any solutions?


Before any actions

After launching ngrok

After taskkill

dheb
  • 21

1 Answers1

0

The problem that I see is your use of the call command within your start command.

call is only used within a batch process to invoke functionality from within other batch processes (either by label or file).

ex:
call :MyLabel <- where MyLabel is a label defined in the same file.
or
call "c:\mypath\dumb.bat" <- after this batch runs, it will continue from here

In this case, this is not what you wan't as these are the only uses for call.

A quick lesson about the call command

Also, even though this wasn't what you wanted.. since we are on the subject of when to use call.. Why not simply use goto or directly invoke a batch file?

The reason for the label method is that call can be used like a function by calling a batch label. After the label is called, the code after the label (sort of like a function) can return to where the call statement was invoked by either using goto :EOF or exit /b creating a very "function like" behavior within batch. In the before times, this was like GoSub and Return used in basic.

If you don't use call when invoking a batch file from another batch file, the process will simply exit after invoking the second batch file (leaving one bewildered as to why the batch stopped).

OTHERWISE, DON'T USE IT! :)