Here-Document on new Install

I have purchased a new system with Windows 10 Pro, and have installed;
Code:
TCC  24.02.49 x64   Windows 10 [Version 10.0.17763.503]
On my previous Windows 7 system, the following example worked as it should;
Code:
@setlocal
@echo off
type <<- endtext > results.txt
This is parameter %1
endtext
type results.txt
endlocal
However, it does not work on my Windows 10 Pro system, due to how I installed Windows 10 Pro.

On my Windows 7 system, my USERPROFILE was in C:\Users\jlc

On my Windows 10 system, my USERPROFILE is in C:\Users\Joe Caverly

When I run the above example, it returns with an error;
Code:
e:\utils>test.btm
TCC: (Sys) E:\Utils\test.btm [5]  The system cannot find the file specified.
"C:\Users\Joe"
Yes, in hind sight, I should have setup a user profile with no spaces, but is there a way I can eliminate this error?

Joe
 
May 20, 2008
9,425
63
Syracuse, NY, USA
What's the connection between the error and the code? It's noy obvious. Line 5 is "endtext"; I wouldn't expect a file_not_found error there.
 
Nor would I.

It would seem that some sort of piping is taking place, and while it worked previously with my no-space userprofile, it no longer works with my one-space userprofile.

I think that maybe it is somehow trying to read/write to;
Code:
c:\users\joe caverly\appdata\local\jpsoft
...and cannot do so, due to the space in the path.

Joe
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,853
48
Albuquerque, NM
prospero.unm.edu
Trying to think of a more elegant way. Do you have admin access to this machine? Perhaps you could
Code:
mklink /d c:\users\JLC "c:\users\joe caverly"
and then redefine the TEMP and TMP variables accordingly.

But really, you shouldn't have to do any of this. Piping should not break just because your temp directory has a funky name. I think you have uncovered a bona fide bug in need of correction.
 
But really, you shouldn't have to do any of this. Piping should not break just because your temp directory has a funky name. I think you have uncovered a bona fide bug in need of correction.
Not a bug, but an "Undocumented feature".

Yes, I am running as Administrator. I have added the following to my TCSTART.BTM;
Code:
  if not exist c:\users\jlc mklink /d c:\users\JLC "c:\users\joe caverly"
  set temp=C:\Users\jlc\AppData\Local\Temp
  set tmp=C:\Users\jlc\AppData\Local\Temp
...and my test code works!

Joe
 
Aug 23, 2010
388
5
If a program intended to work with files fails to interpret a filesystem path, it's a bug.
But, frankly speaking, who make usernames with spaces?
If you want a "mail name", there's a special field in user's attributes for that.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,853
48
Albuquerque, NM
prospero.unm.edu
I don't have access to the source, but I think I can guess how it works. I'll bet the chunk of text between <<- and ENDTEXT is written to a temp file, and then the original command line is massaged, changing the << ENDTEXT to <filename. And Rex is writing the filename verbatim, without quote marks, because who the hell creates a temp directory with spaces? If I'm right, it should be a one-line fix.
 
May 20, 2008
9,425
63
Syracuse, NY, USA
Back to the beginning. Is this even a valid use of a here-document?
Code:
type <<- endtext > results.txt
This is parameter %1
endtext
From the help:
The current batch file is read up to the next occurrence of word, and the resulting text becomes standard input to program.
TYPE isn't expecting any standard in (except perhaps a few keystrokes to dismiss pauses). I think a proper use of a here document looks more like this:
Code:
v:\> type lucky.btm
nslookup <<- endinput > lookupresults.txt
lucky.syr.edu
exit
endinput
I think that TYPE working with a here-document is a fluke.

In any event, there's still a problem. Even the correct (?) usage (lucky.btm, above) suffers when TEMP/TMP contains a spece.
 
May 20, 2008
9,425
63
Syracuse, NY, USA
It's not documented, but TYPE as a filter is an old feature, predating here-documents. In fact I think it goes back to 4DOS.
Code:
ipconfig | type /l
I didn't know that; it's not mentioned in the 4DOS printed manual. "/P" doesn't work in that scenario ... too bad, it could be used like MORE.
 
Not that it matters, but I note that during the install of some other software packages, they seem to be using the Short-File name when writing to the %TEMP folder, that is;
Code:
e:\utils>echo %@sfn[C:\Users\Joe Caverly\AppData\Local\Temp]
C:\Users\JOECAV~1\AppData\Local\Temp
After doing much googling, it would appear that it is not uncommon for the %USERPROFILE to contain spaces, but a %USERPROFILE with no spaces makes things simpler.

Joe
 
May 20, 2008
9,425
63
Syracuse, NY, USA
In ControlPanel\UserAccounts is "Change your account name". I don't know how far the change actually goes; maybe it'll rename the profile directory.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,853
48
Albuquerque, NM
prospero.unm.edu
Not that it matters, but I note that during the install of some other software packages, they seem to be using the Short-File name when writing to the %TEMP folder, that is;
Code:
e:\utils>echo %@sfn[C:\Users\Joe Caverly\AppData\Local\Temp]
C:\Users\JOECAV~1\AppData\Local\Temp
So your fix might be as simple as
Code:
set temp=%@sfn[%temp]
set tmp=%@sfn[%tmp]
Or the equivalent via the environment control panel.
 
May 20, 2008
9,425
63
Syracuse, NY, USA
What's the default 8dot3 setting on Win10? I changed mine from 2 (volume specific) to 1 (disabled on all volumes) but I don't know what the volume specific settings were before that. Find out with, for example,
Code:
fsutil 8dot3name query [drive:]
 
On my brand new install of Windows 10 Pro;

Code:
e:\utils>fsutil 8dot3name query c:
The volume state is: 0 (8dot3 name creation is enabled).
The registry state is: 2 (Per volume setting - the default).

Based on the above settings, 8dot3 name creation is enabled on c:

e:\utils>fsutil 8dot3name query e:
The volume state is: 1 (8dot3 name creation is disabled).
The registry state is: 2 (Per volume setting - the default).

Based on the above settings, 8dot3 name creation is disabled on e:
2327

Joe