Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for better and faster .net batch prologue #25

Open
SergeAgeyev opened this issue Nov 21, 2019 · 0 comments
Open

Suggestion for better and faster .net batch prologue #25

SergeAgeyev opened this issue Nov 21, 2019 · 0 comments

Comments

@SergeAgeyev
Copy link

There is some suggestions to improvement on .net batch prologue.
(as a source screenCapture.bat was used)

  1. If screenCapture.exe already exist, better to call immediately, skipping search for csc.exe
  2. screenCapture.bat produces screenCapture.exe at the place where it called, not where screenCapture.bat is located. if called from multiple laces produces many screenCapture.exe
  3. if you call it from "another.bat" file located in the same folder using "sibling" pattern "call %0..\screenCapture", it will not compile (as ".bat" extension may not be added to "%0" inside screenCapture.bat under Win7)

Here is updated prologue I use:

// 2>nul||@goto :batch
/*
:batch
@echo off
if exist "%~dpn0.exe" (
"%~dpn0.exe" %*
exit /b %errorlevel% 
)

setlocal
:: find csc.exe
set "csc="
for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do  set "csc=%%#"

if not exist "%csc%" (
   echo no .net framework installed
   exit /b 10
)

call %csc% /nologo /r:"Microsoft.VisualBasic.dll" /out:"%~dpn0.exe" "%~dpn0.bat" || (
   exit /b %errorlevel% 
)

"%~dpn0.exe" %*
endlocal & exit /b %errorlevel%

*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant