1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

detach caveat

Discussion in 'Support' started by Stefano Piccardi, Sep 12, 2008.

  1. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    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)
    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
     

Share This Page