[Undocumented] SUBST

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

[Undocumented] SUBST

Post by MigrationUser »

27 Nov 2012 07:38
carlos

Hello. I'm not really sure if this was documented before. But, some seconds ago I found this for error and I'm really surprised and happy of the result.
I using Windows 7.
I found that SUBST command accept other letters in the drive letter (not the typical A-Z of all the life), but Windows Explorer only shows the A-Z letters:

I use for example:

Code: Select all

SUBST $: "%TEMP%"
And now you not view the $ in the window explorer, but if you use:

Code: Select all

$:
No, you have in the Temp directory, but mapped with the volume $:
Also, I use:

Code: Select all

SUBST :: "%TEMP%"
SUBST !: "%TEMP%"
SUBST 9: "%TEMP%"
and many other characters.

Then, this have some benefits. You can map a folder as a volume inside a batch, and you not view this in the explorer of windows. Also, you can increment the possibilities of map a drive letter unused.

Also, I found that subst command executed without parameters, show the folder mapped with it, but only A-Z
If you use for example:

Code: Select all

SUBST #: "%TEMP%"
SUBST B: "%TEMP%"
And you run SUBST you get:

Code: Select all

B:\: => C:\Users\Carlos\AppData\Local\Temp
but you not be informed of the existence of #: you only can remember it.


Carlos.

Last edited by carlos (27 Nov 2012 09:26)

----------------------------

#2 14 Jul 2013 19:24
Simon Sheppard

I have added a note about this to the SUBST page - thanks Carlos

----------------------------

#3 02 Aug 2013 02:03
probyn

I read this post a while ago and something was nagging me about it. Do any of these show up when you type 'set "' at the CMD prompt? (That's S E T <space> <double-quote> ) The so-called 'undocumented system variables' should include the names of whatever directories are current on whatever various hard drives you have, etc. (There won't be any in the list if you haven't referenced any in your current console session.)

----------screen capture Win 7------------------
C:\Users\Phil>set "
=::=::\
=C:=C:\Users\Phil
=D:=D:\
=E:=E:\
=F:=F:\Wylbur
=G:=G:\
=K:=K:\CMD\DATA
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Phil\AppData\Roaming
cmdpath=c:\Cmd;c:\Cmd\test;c:\Cmd\util
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
etc., etc., etc.,
-----------end screen capture---------------------

I have some SUBSTs in effect but only in WinXP under WinVPC

H:\: => UNC\tsclient\c
K:\: => UNC\tsclient\k
X:\: => UNC\tsclient\f

to access the host Win 7 hard drive; these don't show up for
me in the output of 'set "'.

--
Phil Robyn
Univ. of California, Berkeley
ude tod yelekreb ta nyborp

----------------------------

#4 02 Aug 2013 15:07
dbenham

Yes - They show up for me in Win7 once the mapped drive is referenced. The variable remains even after the mapped drive is undefined!

Code: Select all

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

P:\>set ^"|findstr "^="
=P:=P:\

P:\>subst $: "%temp%"

P:\>set ^"|findstr "^="
=ExitCode=00000000
=P:=P:\

P:\>$:

$:\>p:

P:\>set ^"|findstr "^="
=$:=$:\
=ExitCode=00000000
=P:=P:\

P:\>subst $: /d

P:\>set ^"|findstr "^="
=$:=$:\
=ExitCode=00000000
=P:=P:\

P:\>$:
The system cannot find the drive specified.

P:\>set ^"|findstr "^="
=$:=$:\
=ExitCode=00000000
=P:=P:\

P:\>
Dave Benham

----------------------------

#5 05 Feb 2014 23:23
SmartGenius

Esto me ha gustado bastante, siempre me he apegado a las "reglas de sintaxis" de cada comando y en base a ello hago cosas, tu experimentas nuevas posibilidades wink

el comando SUBST es la base del script de "Virtual Drive" (si lo recuerdas) y con este descubrimiento quedaria aun mejor al no reflejarse en el explorador cual es la unidad que usa para guardar las cosas, o hacer algo aun mejor ;)

Saludos brother
Post Reply