Computer Hope

Microsoft => Microsoft DOS => Topic started by: karlosss on May 20, 2017, 06:25:16 AM

Title: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: karlosss on May 20, 2017, 06:25:16 AM
who knows to create a script.bat  to stop my tool.exe process when i get a type of error 12 times in a row?
thank you
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: DaveLembke on May 20, 2017, 08:18:42 AM
Curious how your thinking of implementing this with batch. What will be used as a flag that an error happened 12 times. Do you have a log file that is created to where a batch can monitor this log file for 12 instances of an error and then perform a taskkill to tool.exe when 12 instances of some error message is found?

Errorlevels might be able to be used if the error reports to command shell and upon error the program doesnt just hang at the error but times out and/or moves on so that you can get the 12 instances of an error maybe. http://www.robvanderwoude.com/errorlevel.php

More here on detecting problems with errorlevels http://stackoverflow.com/questions/13150676/using-errorlevel-in-a-batch-file-to-know-if-a-program-exited-normally
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: patio on May 20, 2017, 08:22:03 AM
You aren't learning anything having all these .bat files written for you...Just sayin...
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: Salmon Trout on May 20, 2017, 09:29:55 AM
You aren't learning anything having all these .bat files written for you...Just sayin...

Interesting to view his posting history. Just sayin...
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: Hackoo on May 20, 2017, 10:45:34 AM
Hi  ;)
If you know what is the exit code from your tool.exe, you can of course deal it with a batch file ;)
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: karlosss on May 20, 2017, 10:50:02 AM
Curious how your thinking of implementing this with batch. What will be used as a flag that an error happened 12 times. Do you have a log file that is created to where a batch can monitor this log file for 12 instances of an error and then perform a taskkill to tool.exe when 12 instances of some error message is found?

Errorlevels might be able to be used if the error reports to command shell and upon error the program doesnt just hang at the error but times out and/or moves on so that you can get the 12 instances of an error maybe. http://www.robvanderwoude.com/errorlevel.php

More here on detecting problems with errorlevels http://stackoverflow.com/questions/13150676/using-errorlevel-in-a-batch-file-to-know-if-a-program-exited-normally

i use AlwaysUP to schedule and run my tool.exe As system service,please take a look here ,u think is possible?
https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForError

this is the error code:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:

Now stop MyTool.exe when finds more then 10 errors in a row
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: Hackoo on May 20, 2017, 09:05:42 PM
Hi  ;)
You can give a try for this script :
Code: [Select]
@echo off
Mode con cols=80 lines=5 & color 9E
set "MyProcess=MyTool.exe"
Title Monitoring the process "%MyProcess%" for error by Hackoo 2017
Set "StopProcess=StopProcess.log"
Set "MyLogFile=Log.log"
Set "ErrorMsg=Dropping connection limit due to connection error to"
:MainLoop
cls
Set /a "ErrorLimit=10"
Set /a "Count=0"
@For /f %%A in ('Type "%MyLogFile%" ^| find /I "%ErrorMsg%"') Do (
Set /a Count+=1
)
SET Count=00%Count%
SET Count=%Count:~-2%
echo(
echo                 Monitoring the process "%MyProcess%" for error
echo              The Counting of error message until now is = "%Count%"
echo        The ErrorLimit is set by the script = "%ErrorLimit%" for stopping this process
If "%Count%" GEQ "%ErrorLimit%" (
Goto KILLPROCESS
) else (
echo The counting of error = %Count% > "%StopProcess%"
Timeout /T 60 /Nobreak >nul
)
Goto MainLoop
::****************************************************************
:KILLPROCESS
echo The counting of error is reached to %Count% > "%StopProcess%"
Taskkill /IM "%MyProcess%" /F >> "%StopProcess%" 2>&1
Timeout /T 60 /Nobreak >nul & Goto MainLoop
Exit /b
::****************************************************************
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: Geek-9pm on May 20, 2017, 10:18:31 PM
A brief note about programming languages.

If the OP has a hard time with batch files, he might consider looking into an approach that makes things easier. There are a number of tools that have been created to make it easy to perform some kinds of update and maintain things  res on a PC.
Here are just a few better programming tools to save time and reduce unwanted errors. They all begin with the Letter P.

P#
Pearl
PHP
Pizza
PL/M
PostScript
Powershell
Prolog
Python

All the above have features that could make programming easier if you get stuck with a batch file problem. Some experts  say you can not mix one language with another. I disagree, that is what I used to do years ago and I believe that kind of approach is still a good idea. Some experts  do not like it because it is not "Pure". Well, there is a language called "Pure" and it is tolerant.

[Pure is a small language designed from scratch; its interpreter is not large, and the library modules are written in Pure.]

But even "Pure" will let you invoke other stuff if need be.

The pint I wish to make is the OP might consider looking around and trying to add to his skills. 

I will stop here. Just saying that the OP ought to do wider  study of programming. Looking at another language might help.  8)
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: karlosss on May 21, 2017, 12:22:37 AM
A brief note about programming languages.

If the OP has a hard time with batch files, he might consider looking into an approach that makes things easier. There are a number of tools that have been created to make it easy to perform some kinds of update and maintain things  res on a PC.
Here are just a few better programming tools to save time and reduce unwanted errors. They all begin with the Letter P.

P#
Pearl
PHP
Pizza
PL/M
PostScript
Powershell
Prolog
Python

All the above have features that could make programming easier if you get stuck with a batch file problem. Some experts  say you can not mix one language with another. I disagree, that is what I used to do years ago and I believe that kind of approach is still a good idea. Some experts  do not like it because it is not "Pure". Well, there is a language called "Pure" and it is tolerant.

[Pure is a small language designed from scratch; its interpreter is not large, and the library modules are written in Pure.]

But even "Pure" will let you invoke other stuff if need be.

The pint I wish to make is the OP might consider looking around and trying to add to his skills. 

I will stop here. Just saying that the OP ought to do wider  study of programming. Looking at another language might help.  8)

I use AlwaysUP to run my tool.exe and ... alwaysup have this option too can u help me config. please?
https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForError
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: karlosss on May 21, 2017, 12:23:38 AM
Hi  ;)
You can give a try for this script :
Code: [Select]
@echo off
Mode con cols=80 lines=5 & color 9E
set "MyProcess=MyTool.exe"
Title Monitoring the process "%MyProcess%" for error by Hackoo 2017
Set "StopProcess=StopProcess.log"
Set "MyLogFile=Log.log"
Set "ErrorMsg=Dropping connection limit due to connection error to"
:MainLoop
cls
Set /a "ErrorLimit=10"
Set /a "Count=0"
@For /f %%A in ('Type "%MyLogFile%" ^| find /I "%ErrorMsg%"') Do (
Set /a Count+=1
)
SET Count=00%Count%
SET Count=%Count:~-2%
echo(
echo                 Monitoring the process "%MyProcess%" for error
echo              The Counting of error message until now is = "%Count%"
echo        The ErrorLimit is set by the script = "%ErrorLimit%" for stopping this process
If "%Count%" GEQ "%ErrorLimit%" (
Goto KILLPROCESS
) else (
echo The counting of error = %Count% > "%StopProcess%"
Timeout /T 60 /Nobreak >nul
)
Goto MainLoop
::****************************************************************
:KILLPROCESS
echo The counting of error is reached to %Count% > "%StopProcess%"
Taskkill /IM "%MyProcess%" /F >> "%StopProcess%" 2>&1
Timeout /T 60 /Nobreak >nul & Goto MainLoop
Exit /b
::****************************************************************

ok thank you, i will try your script
Hackoo i use AlwaysUP scheduler to run my Tool.exe  As System and we have this option can u try to configure it please?take a look here
https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForError
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: patio on May 21, 2017, 05:53:52 AM
There's no need to Quote all the replies to your posts...

Thank You.
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: karlosss on May 21, 2017, 09:33:16 AM
can u stop also cmd.exe and my tool.exe too?
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: Geek-9pm on May 21, 2017, 10:34:20 AM
karlosss,
CMD.EXE is a part of Windows and is used to start batch files.
tool.exe is not identified as a standard item in Windows.
Some say that is the name used by malware.
Please explain where you got the tool.exe program, because we just can not guess what it is supported to do.

Here is just one of many links about tool.exe.
https://www.tenforums.com/software-apps/45148-software-reporter-tool-exe.html
So such a generic name makes for confusion.  :-\
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: karlosss on May 21, 2017, 12:03:58 PM
i have a Script.bat who runs my tool.exe
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: Geek-9pm on May 21, 2017, 12:41:53 PM
i have a Script.bat who runs my tool.exe
What is tool.exe?
If it is from a credulous publisher, it would have documentation that would help.
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: DaveLembke on May 21, 2017, 12:45:36 PM
Geek-9pm caught my attention with this, and user name rang a bell with RDP stuff from past which was odd, so I decided to go looking at history:

Quote
CMD.EXE is a part of Windows and is used to start batch files.
tool.exe is not identified as a standard item in Windows.
Some say that is the name used by malware.
Please explain where you got the tool.exe program, because we just can not guess what it is supported to do.

Looking at past post history here with ncrack and RDP tricks. Hopefully this isnt a tool we are assisting in the creation of "bending" a Tool.exe program around batch or other code using it with questionable intent. Below is link of Karlosss history.

https://www.computerhope.com/forum/index.php?action=profile;u=158444;area=showposts;start=30
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: patio on May 21, 2017, 12:48:44 PM
As he is already a resident of our Moderator watch list we'll see what kind of response is forthcoming...
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: karlosss on May 21, 2017, 01:07:58 PM
no no this type is not about rdp
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: Geek-9pm on May 21, 2017, 01:17:18 PM
As he is already a resident of our Moderator watch list we'll see what kind of response is forthcoming...
I read the first post that was given by DaveLembke.

Yes, his request does seem to be in the suspicions category.
In that other post he has a computer in the same room and wants to turn it on by remote control.  ::)
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: karlosss on May 21, 2017, 01:38:32 PM
ok if u think that please close the thread and everything will be ok
thanks for everything guys
Title: Re: who knows to create a script to stop my tool.exe process when i get a type of er
Post by: patio on May 21, 2017, 03:25:10 PM
Topic Closed.

patio.