Redirection to clip - env dependency?

Apr 13, 2010
The Hague
For testing purposes, especially for hunting down dependencies and side-effects, I run pieces of code in an env with all aliases and envars removed. If it crashes I put back in and document what's needed and influenced.

That's how I came accross this simple line:
resolution > clip:
and was surprised to find that restoring the PATH envar is not enough.
TCC: (Sys) C:\Users\dj\Batch\test.btm [31]  Access denied. C:\WINDOWS\COUTf14.JPS"

PATH points to all the usual places, including _windir.
Which dependency am I missing?

May 20, 2008
Elkridge, MD, USA
I believe it is environment variable TMP, or in its absence, TEMP. The age old rule of Windows itself, as well as of most programs written for Windows, is that if a directory for temporary files is not explicitly specified, the first choice is specified by %TMP if TMP is defined; second choice is %TEMP if TEMP is defined. If neither is defined, the currently running program's directory is used (for the redirection, that's Windows itself). This last element of the search has always conflicted with keeping programs safe from corruption. Apparently your version of Windows (Vista or later?) provides the safety aspect by requiring special privileges to write in the program's directory, but without changing the search rule...

Define TMP or at least TEMP, and your problem ought to be solved...
HTH, Steve


Staff member
May 14, 2008
To elaborate slightly on what Steve said, since the CLIP: device doesn't actually exist in Windows, TCC needs to create a temporary file in order to emulate a device. TCC tries to create the temporary file in the path specified by (in order):
  1. The path specified by the TMP environment variable
  2. The path specified by the TEMP environment variable
  3. The path specified by the USERPROFILE environment variable
  4. The Windows directory
In recent versions of Windows, #4 will fail unless you're running in an elevated session.
Similar threads
Thread starter Title Forum Replies Date
vefatica Redirection and memory leak? Support 3
A WAD Output redirection to IF block fails with "unbalanced brackets" Support 7
N multiple command alias and redirection Support 0
nikbackm Switch Case and here-document redirection Support 2
M Piping and redirection: CON: Support 5
J WAD Output redirection in tcexit looses data Support 31
J Vers. 18 Here doc redirection broken? Support 4
vefatica Redirection vs. piping? Support 4
I "IF" command in a variable does not expand redirection variable name Support 0
P Fixed TCC 17 describe redirection Support 3
vefatica Speeding up redirection to NUL? Support 32
fpefpe WOW64 Redirection Support 8
W redirection with pipe don't work Support 10
A Dual redirection Support 3
krischik I/O redirection with start command. Support 6
L redirection to/by perl acts bizarrely Support 9
Charles Dye Strange output, here-doc redirection, TYPE, //UnicodeOutput=Yes Support 6
Daniel Wee Rexx output redirection seems to be broken Support 4
H "Here-String" redirection not working Support 6
Kachupp Documentation @clip Support 4
vefatica Can DIRHISTORY read from clip:? Support 2
D Copy to clip changes character Support 24
vefatica Get CLIP: into a MSGBOX? Support 2
S @clip peculiarity Support 25
S CLIP file size limit Support 1
mikea Listing "@clip:" Support 1
mikea TCC11 newbie question re using '>>clip:' Support 11
L WAD ECHO. expansion of non-existent env-vars differs from CMD.exe Support 6
M How to make Lua modify env-vars Support 18
MickeyF how to work with env var with special characters in the name Support 5
noahcoad How to? Create shortcut with env var in path Support 4
C Env vars in tcmd.ini Support 12
N Can't set an env variable via pipe Support 8

Similar threads