npocmaka / batch.scripts

batch script utils and examples by npocmaka -
https://www.linkedin.com/in/npocmaka/
MIT License
1.07k stars 874 forks source link

Speedup optimisation for .net batch files #22

Closed SergeAgeyev closed 4 years ago

SergeAgeyev commented 5 years ago

Absolutely great job!

Just one suggestion to speedup operation in .net bat files: Add if exist "%~n0.exe" %~n0.exe %* just after begin of bath body, so it will not search for .net framework if to compile .net part if it is already compiled (if compiled .exe exists, it will run it immediately):

Was:

:batch
@echo off
setlocal

Faster:

:batch
@echo off
if exist "%~n0.exe" (
"%~n0.exe" %*
exit /b %errorlevel% 
)
setlocal

PS: Edited: Added exit after execution

npocmaka commented 5 years ago

Very good idea! When I have the time I'll update the .net hybrids.

SergeAgeyev commented 4 years ago

I have provided more details and better solution in issue #25