- May
- 382
- 2
If a batch file executes
DETACH "%variable%"
I can see with Process Explorer that TCC starts
C:\TCMD\tcc.exe /c "%variable%"
where %variable% is left for the detached process to expand.
The caveat is that if %variable% is an expression that includes %_batchname then tcc.exe /c will most likely not expand it as intended, since %_batchname is undefined at that point.
I'm sure Rex has a good reason for designing DETACH this way; so the work-around for me is to
SET bn=%_batchname
DETACH "%bn%"
as illustrated in the following script (unREM the second DETACH line to see the effect)
DETACH "%variable%"
I can see with Process Explorer that TCC starts
C:\TCMD\tcc.exe /c "%variable%"
where %variable% is left for the detached process to expand.
The caveat is that if %variable% is an expression that includes %_batchname then tcc.exe /c will most likely not expand it as intended, since %_batchname is undefined at that point.
I'm sure Rex has a good reason for designing DETACH this way; so the work-around for me is to
SET bn=%_batchname
DETACH "%bn%"
as illustrated in the following script (unREM the second DETACH line to see the effect)
Code:
setlocal
iff .%1 == .DETACHED then
OSD /time=3 /hcenter /vcenter running %_pid detached
else
echo detaching "%_batchname"
detach "%_batchname" DETACHED & rem starts nothing
set bn=%_batchname
REM detach "%bn%" DETACHED & rem starts %_batchname
endiff