Break-out common functionality between elasticsearch.bat and service.bat Relates #8237 (cherry picked from commit 87095e79534bcef97b2b275322c924bd96b34e3b)