Enhancement to @PID function...

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
I do almost all of my actual coding work in "temporary" directories that are stored on my RAM disk (speed, fragmentation is not an issue at all compared to physical disk drives). When I am done with a project/directory, my habit is to copy the contents of that directory back to a physical hard disk and then delete the temporary directory as a clean-up step. Here is a sample command sequence illustrating the problem:
[Z:\]rd SampleDirectory
TCC: (Sys) The process cannot access the file because it is being used by anoth
r process.

[Z:\]handle SampleDirectory
Handle v3.46
Copyright (C) 1997-2011 Mark Russinovich
Sysinternals - www.sysinternals.com
tcc.exe            pid: 4136   type: File           4A4: Z:\SampleDirectory

[Z:\]tasklist tcc*
  712  tcc               TCC Prompt
 2912  tcc               TCC Prompt
 4136  tcc               TCC Prompt
  496* tcc               Administrator: TCC Prompt - tasklist tcc*
As you can see, TCC PID 4136 still has a "handle" on that directory, but I have three non-elevated TCC command sessions open, and I know of no way determine which of those sessions has the actual "handle" on that directory that should either be freed or that session closed. And I will also add that, since I am a heavy "multitasker", I can have as many as 10 to 12 TCC sessions active at any one time (I have one open for basically every "project" that I am working on concurrently, where a "project" is a series of commands that are repeatedly executed in a general sequence on a basically one-time only basis so "command history" but no .btm file is involved, not necessarily a "programming project".) So some argument such as an asterisk, for example, ("Echo PID
[*]") to indicate the PID of the current TCC session would really be useful.
On Thu, 09 Jun 2011 02:33:17 -0400, mathewsdw <> wrote:

|("Echo PID[*]") to indicate the PID of the *current* TCC session would really be useful.

There's always "ECHO %_PID".
There's always "ECHO %_PID".
Vince, you are of course correct. I was not aware of that internal variable. Also, that command may easily placed in a single-line .btm file (that will take up litterally no disk storage space at all because it will be small enough to fit entirely in the NTFS MFT) to make that information even easier to get! Thank you!
I put the PID (obtained via %_pid) in the title of each TCC session, using
the TITLEPROMPT variable. This can be utilized with the ACTIVATE command to
quickly switch to a specific TCC instance.
HTH, Steve