batch
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| batch [2016/06/29 06:18] – skipidar | batch [2020/12/27 20:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 84: | Line 84: | ||
| # delete | # delete | ||
| subst z: b: | subst z: b: | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | === SCRIPT to find java process by command line argments === | ||
| + | |||
| + | Name it findJavaProcessByCommandline.bat | ||
| + | Usage: | ||
| + | |||
| + | < | ||
| + | call findJavaProcessByCommandline.bat javaCommandLinePart | ||
| + | if errorlevel 1 echo NoFindings & exit /b 1 | ||
| + | </ | ||
| + | |||
| + | |if errorlevel 1 | check result of nested script. 1 if nothing found| | ||
| + | |echo NoFindings | Echo| | ||
| + | |& exit /b 1| and exits the parent script. Instead you can do whatever you want with this info | | ||
| + | |||
| + | < | ||
| + | @echo off | ||
| + | |||
| + | :: check if empty | ||
| + | IF [%1] == [] GOTO noarg | ||
| + | |||
| + | :: use the argument | ||
| + | set likeString=%1 | ||
| + | |||
| + | |||
| + | setlocal EnableDelayedExpansion | ||
| + | set processIdFinding= | ||
| + | for /f %%i in ('wmic process where " | ||
| + | set processIdFinding=!processIdFinding!%%i | ||
| + | ) | ||
| + | |||
| + | if " | ||
| + | goto nofindings | ||
| + | ) else ( | ||
| + | goto findings | ||
| + | ) | ||
| + | |||
| + | :nofindings | ||
| + | echo Nothing Found | ||
| + | exit /b 1 | ||
| + | |||
| + | :findings | ||
| + | echo Finding: %processIdFinding% | ||
| + | exit /b 0 | ||
| + | |||
| + | :noarg | ||
| + | echo Please provide the Stringto be searched withing java process commandline as an argument | ||
| + | exit /b 1 | ||
| </ | </ | ||
batch.1467181133.txt.gz · Last modified: (external edit)
