Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Cmd, use variables in conjunction with path completion.

07 Aug 2010   #1
Neutrino

Win7 Pro
 
 
Cmd, use variables in conjunction with path completion.

Subject says it all really. If I use an environment variable on the commandline in a path it apppears to stop path completion from working correctly. In the example below on the last line I hit TAB after typing "dir %userprofile%\do" and instead of the path completion acting on the expanded %userprofile% variable and coming up with Documents it instead just retrieved the first hit for "do" from the root (current) directory.

Is there a fix or workaround for this as the inability to use environment variables and path completion together is really annoying?

Code:
C:\>echo %userprofile%
C:\Users\MyName

C:\>dir %userprofile%
 Volume in drive C has no label.
 Volume Serial Number is ACA3-CBF7

 Directory of C:\Users\MyName

06/08/2010  12:39    <DIR>          .
06/08/2010  12:39    <DIR>          ..
01/07/2010  09:27    <DIR>          Contacts
06/08/2010  15:09    <DIR>          Desktop
07/08/2010  10:45    <DIR>          Documents
07/08/2010  10:48    <DIR>          Downloads
01/07/2010  09:27    <DIR>          Favorites
01/07/2010  09:27    <DIR>          Links
07/08/2010  10:46    <DIR>          Music
07/08/2010  10:46    <DIR>          Pictures
01/07/2010  09:27    <DIR>          Searches
07/08/2010  10:46    <DIR>          Videos
               1 File(s)             85 bytes
              16 Dir(s)  43,400,957,952 bytes free

C:\>dir %userprofile%"\Documents and Settings"



My System SpecsSystem Spec
.

07 Aug 2010   #2
Dzomlija

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by Neutrino View Post
Subject says it all really. If I use an environment variable on the commandline in a path it apppears to stop path completion from working correctly. In the example below on the last line I hit TAB after typing "dir %userprofile%\do" and instead of the path completion acting on the expanded %userprofile% variable and coming up with Documents it instead just retrieved the first hit for "do" from the root (current) directory.

Is there a fix or workaround for this as the inability to use environment variables and path completion together is really annoying?

Code:
C:\>echo %userprofile%
C:\Users\MyName
 
C:\>dir %userprofile%
 Volume in drive C has no label.
 Volume Serial Number is ACA3-CBF7
 
 Directory of C:\Users\MyName
 
06/08/2010  12:39    <DIR>          .
06/08/2010  12:39    <DIR>          ..
01/07/2010  09:27    <DIR>          Contacts
06/08/2010  15:09    <DIR>          Desktop
07/08/2010  10:45    <DIR>          Documents
07/08/2010  10:48    <DIR>          Downloads
01/07/2010  09:27    <DIR>          Favorites
01/07/2010  09:27    <DIR>          Links
07/08/2010  10:46    <DIR>          Music
07/08/2010  10:46    <DIR>          Pictures
01/07/2010  09:27    <DIR>          Searches
07/08/2010  10:46    <DIR>          Videos
               1 File(s)             85 bytes
              16 Dir(s)  43,400,957,952 bytes free
 
C:\>dir %userprofile%"\Documents and Settings"
The reason why you get "Document and Settings" when you press <TAB> to activate code completion is because you're in the root of the drive. I've just tested this, and got two different results. I highlighted what I typed before pressing <TAB>:
Code:
 
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Users\Peter Dzomlija>dir Documents
 Volume in drive C has no label.
 Volume Serial Number is 365F-53AD
 Directory of C:\Users\Peter Dzomlija\Documents
07/08/2010  08:10    <DIR>          My PSP Files
               0 File(s)              0 bytes
               1 Dir(s)  22,641,709,056 bytes free
C:\Users\Peter Dzomlija>cd\
C:\>dir "Documents and Settings"
 Volume in drive C has no label.
 Volume Serial Number is 365F-53AD
 Directory of C:\Documents and Settings
File Not Found
C:\>
Code completion works on the current contents of a folder only, and does not reparse subfolders, nor does it expand environment variables. The EV expansion only comes into play when the command/s is executed.
My System SpecsSystem Spec
07 Aug 2010   #3
Neutrino

Win7 Pro
 
 

If you enter a multipart path like:

c:\>dir \Users\

and then press TAB on my system the path completion does in fact correctly list the contents of any subdirectories the path links to, so it doesn't just work on the contents of the current directory.

The only problem is that the environment variables are not expanded into the path when this lookup process occurs, and since I assume the path lookup is performed by the command processor itself (cmd.exe) rather that any invoked command that seems like choice of behaviour that's neither intuitive nor useful.
My System SpecsSystem Spec
.


Reply

 Cmd, use variables in conjunction with path completion.




Thread Tools





Similar help and support threads
Thread Forum
System Path variables not passed to NEW CMD prompt.
Random problem or when I install new program or uninstall a program: As I use my pc throughout the day, any new CMD prompts will have a path=(null) and as such I can't use standard windows commands. If I try to go to 'My Computer', 'Properties',... to check on the value of the 'PATH' environment,...
General Discussion
Invalid path in environment variables. Safe to delete?
Hi. Is it safe to delete the entry shown? I don't see a folder anywhere on C: (windows partition) named BVTBin even with super-hidden files shown. I'm asking because I don't understand why the entry exists.
Performance & Maintenance
accidentally deleted path in environment variables
i was editing the path in environment variables after installing jdk-6.0 when i accidentally deleted it...is there a way to recover it? or if not , can somebody tell me what was the default variable path was that? i'm using windows 7 starter...and a toshiba laptop.....please i really need help...
System Security
CMD tab completion stopped working
I am running Win 7 and I checked the registry key: CompletionChar and PathCompletionChar, they are both set to 26, I've also tried changing it to 9. None of it works. When I type in the command prompt and hit tab, it just tabs over like it's in a word doc... Thanks for the help!
General Discussion
Setting up bluetooth GPS in conjunction with Microsoft Streets & Trips
:confused:Hello, i am a new membber. My name is lynn. I am totally blind and use a screen reader for all my computing needs. I am attempting to set up a iblue 737a+ gps receiver to my laptop running windows 7. I am totally lost trying to do so?! :) i am *very* new to windows 7 and am afraid...
Network & Sharing
New Wi-Fi standard, 802.11n, nearing completion
Read more at New Wi-Fi standard, 802.11n, nearing completion - Got to love posting things when half awake. ^_^
Network & Sharing

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 17:24.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App