Solved Invalid junction after moving "My Documents"?

if7

New member
Local time
12:46 PM
Messages
9
A number of months ago I followed the "standard" procedure (using the Location property tab) for moving my special folders out of c:\users\xxx to new locations under d:\xxx, where d: is a separate partition on the same hard drive as c:.

As far as I can remember, this generally worked, though it made a mess of AppData by moving only parts of that tree and then failing due to locked files. I had to fix up AppData by hand, and in the end left it in its original location under c:\users\xxx. I successfully moved all of the other movable folders.

I've been having some unusual problems with a new online backup I'm trying out, which seems to be duplicating some files that are in My Documents... without going into all the details of that problem, I started to snoop around to try to see what might be causing the problem, and what I found was a junction in c:\users\xxx to My Documents that is pointing to c:\users\xxx\Documents - a location that does not exist on disk.

> dir /al
04/15/2012 06:05 PM <JUNCTION> My Documents [C:\Users\xxx\Documents]

Except for my problem with backup, things seem to work. But it seems any older program that happens to try to use a hardcoded path to My Documents could fail (or, could end up creating that folder I suppose...?).

If I right-click Documents in the Start menu, it shows 2 library locations: My Documents (D:\xxx) and Public Documents (C:\Users\Public). This seems normal.

If I type "My Documents" into Explorer, it takes me directly to Computer > D > xxx > Documents.

I have an icon for the top level of my user profile on my desktop. When I open it, Explorer shows me a mix of what's in c:\users\xxx and d:\xxx. If I have the folder options set to show protected system files, I see 2 copies of My Documents (one is the folder d:\xxx\Documents, the other is marked as a shortcut and is the junction). This is probably okay, but I'm not sure.

Still - it seems that the junction should have been updated when I moved My Documents, to point to the new location of Documents, no?

It is possible that when I originally switched the location of My Documents, I might have copied rather than moved the files, and then later deleted the original files. I'm not sure what is supposed to happen to that junction if you copy.... besides winding up with duplicate files, obviously. I've since read that copying is a bad thing to do, but not sure why it's an option then. Anyway, not sure if that's what I did, and if so, the best way to fix this.


I have seen people writing about junctions; and seen people writing about moving special folders, or taking it further and relocating their whole user profile; or relocating the whole Users folder. But all of these discussions have been with respect to either using the Location tab, or hacking the registry. I don't recall reading anything about what should happen to the file system junction to My Documents after doing a simple Location change.

Since I know MANY people have relocated My Documents and this is a very common issue, can any one who has relocated it please take a look at the original location and see what the junction shows?

At a command prompt:

> c:
> cd \users\xxx
> dir /al

That will show the junctions.

Does the junction for My Documents point to the correct location, or does it still show the original location at c:\users\xxx\Documents?

Assuming my junction is invalid, perhaps a fix is to back up my data, restore the default location, and then try to move it back again.

But perhaps there is a way to just correct the junction, by either modifying it, or removing it and then recreating it? I'm not familiar with the commands for doing this, and my concern is that during the time I am modifying the folder, I might possibly render my profile nonfunctional.

So perhaps I should do this from an alternate account with administrator privileges...

Any insights, suggestions, etc. would be greatly appreciated!


Thank you.
 

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
Anyone have any thoughts on this issue?
 

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
Code:
cd  %userprofile%
dir /als

What junction points are still there? Do you still have subfolders linke appdata and tracing?
Junction points are for "bad written" programs backwards compatibility btw.

Do you want whole profile to new location?
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
ACER ASPIRE 5742G
OS
Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
CPU
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
Motherboard
Acer Aspire 5742G
Memory
4,00 GB
Graphics Card(s)
ATI Mobility Radeon HD 5400 Series
Sound Card
(1) AMD High Definition Audio Device (2) Realtek High Defi
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
WDC WD5000BEVT-22ZAT0
These are the junction points currently in c:\users\xxx:

04/15/2012 06:05 PM <JUNCTION> Application Data [C:\Users\xxx\AppData\Roaming]
04/15/2012 06:05 PM <JUNCTION> Cookies [C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Cookies]
04/15/2012 06:05 PM <JUNCTION> Local Settings [C:\Users\xxx\AppData\Local]
04/15/2012 06:05 PM <JUNCTION> My Documents [C:\Users\xxx\Documents]
04/15/2012 06:05 PM <JUNCTION> NetHood [C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Network Shortcuts]
04/15/2012 06:05 PM <JUNCTION> PrintHood [C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Printer Shortcuts]
04/15/2012 06:05 PM <JUNCTION> Recent [C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Recent]
04/15/2012 06:05 PM <JUNCTION> SendTo [C:\Users\xxx\AppData\Roaming\Microsoft\Windows\SendTo]
04/15/2012 06:05 PM <JUNCTION> Start Menu [C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Start Menu]
04/15/2012 06:05 PM <JUNCTION> Templates [C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Templates]

The only real folders in c:\users\xxx are AppData and dwhelper.

Showing hidden files reveals all those junctions, plus all the ntuser.dat files.

I don't mind leave AppData here - while it has the Location feature, it doesn't work properly (files are open and won't move). I know there are ways to relocate AppData by hacking registry from some other logon, but I was okay just leaving it here.

I relocated all the other folders (Contacts, Desktop, Documents, Pictures, Videos, etc.)

So the only weird thing is the junction to Documents that points to C - it seems it should point to the current location I moved Documents to, which is D. But I haven't noticed any odd behavior - Windows knows where my Documents are, and obviously ignores this junction. Someday some bad application may depend on it though.

All other users on the system have all their files in c:\users. It's a bare minimal amount of data that I really don't care about enough to change. It's fine for it to all get imaged with my C: drive.

By "move whole profile" I guess you mean moving the whole xxx folder - or even the whole users location? - rather than relocating the separate Documents, Pictures, etc. - but again that might be more than I need on this system. Isn't that best done at the time of a fresh install? And I never had a fresh install - I started with a restore of the Dell factory image.
 

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
(Contacts, Desktop, Documents, Pictures, Videos, etc.) don't have junction points (except documents).
So Contacts, Desktop, Pictures, Videos should work fine. Except if they're hardcoded in registry for some programs.

The 10 junction points you have are fine and are default. 9 of them point to Appdata... look yourself.

Only one junction point is a problem. That's "My Documents" (C:\users\xxx\documents)
Leave it the way it is. In very few cases an old winxp program will create file there instead of real documents folder.
Most likely it creates his own subfolder. You can move it to real documents folder. And change the setting within the program or somewhere in registry. Most of time it's uses as standard save folder.

So it's easy to fix and not a real problem. You still want to redirect it to correct folder?


"move whole profile"... you understand clearly.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
ACER ASPIRE 5742G
OS
Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
CPU
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
Motherboard
Acer Aspire 5742G
Memory
4,00 GB
Graphics Card(s)
ATI Mobility Radeon HD 5400 Series
Sound Card
(1) AMD High Definition Audio Device (2) Realtek High Defi
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
WDC WD5000BEVT-22ZAT0
Okay, thanks - only problem is there is currently no actual Documents folder that the My Documents junction points to.

I think there was, and for a while I renamed it; then, I deleted it. I should probably put it back in case some app does write there.

I got rid of it because in some views of my profile I'd see two copies of My Documents.

If I create it as Documents, then rename it to something like Documents-C, if the junction is updated that will work; otherwise, I have to either name it Documents (and see 2 versions of Documents in some views), or have to modify the junction to point to the right file, in which case I might as well simply point the junction to where my real Documents is, on D!
 

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
Actually the junction is useless. It points to c:\users\xxx\Documents, which I just recreated and in which I placed a dummy text file. I can cd to it, but dir shows the folder is empty. I can only see the file if I list the contents of c:\users\xxx\Documents directly.

I can change the name of c:\users\xxx\Documents. But none of this has any affect on the My Documents junction.

It's quite strange, and what I think I should do is point the junction to my real Documents and get rid of this extra folder I just created - I just don't know how to do that. I'd like the junction to just point to d:\xxx\Documents, which is where I think it should point.
 

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
"my documents" is unreadable!! You can only access stuff by exact name.
You better fix the problem now if you really want.

  1. take ownership of "my documents"... so the junction point itself.
  2. delete the junction file in windows explorer
Now recreate junction I use D:\somewhere\Documents as real destination
Code:
mklink  /J  "C:\Users\xxx\My Documents"  "D:\somewhere\Documents"
Check if it's working. Just double click C:\Users\xxx\My Documents
Now make it hidden and system as it was before. Don't forget /L so it acts on junction itself!
Code:
attrib  +H  +S  +I  "C:\Users\xxx\My Documents"  /L

Finally make it the correct owner and permissions. Don't forget /L so it acts on junction itself!

Code:
icacls "c:\Users\xxx\My Documents" /setowner SYSTEM  /L
icacls "c:\Users\xxx\My Documents" /deny Everyone:(RD)  /L
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
ACER ASPIRE 5742G
OS
Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
CPU
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
Motherboard
Acer Aspire 5742G
Memory
4,00 GB
Graphics Card(s)
ATI Mobility Radeon HD 5400 Series
Sound Card
(1) AMD High Definition Audio Device (2) Realtek High Defi
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
WDC WD5000BEVT-22ZAT0
Thanks! I will follow these instructions. I appreciate your help.
 

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
Okay, it worked! Excellent, thank you again.

There was one small problem I was able to work around:

This first icacls command fails (even when I fixed xxx to be the real name):

> icacls "c:\Users\xxx\My Documents" /setowner SYSTEM /L

Error message is:

c:\Users\xxx\My Documents: This security ID may not be assigned as the owner of this object.
Successfully processed 0 files; Failed processing 1 files

But I was able to set the owner to SYSTEM via Explorer Properties (security, advanced, owner, edit, entered SYSTEM, applied and exited properties, and it worked fine).

The subsequent icacls command, to deny everyone (RD), did work.

Wow. Feeling better about my system now, and when I view my profile in Explorer I'm happy that I only see one documents folder now. (I deleted the extra dummy Documents folder that the junction no longer points to.)

I wonder if Windows 7 always forgets to fix this junction when moving My Documents... I might test it in another account someday.
 

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
I've just come across the exact same situation and I can confirm that it is left over when you do a Move of My Documents. I have tried it several times (after repeatedly doing image restores). I assume it is something that Microsoft never addressed.

My guess is that the vast majority of folks that do such a Move are never aware of the redundant Junction. Unless they go into C:\Users\XXX (with "Hide protected operating system files" disabled) and click on the My Documents, you don't tend to come across it. And unless they run into issues with software accessing the junction via hard coded paths in software it will never become an issue.

At the moment I haven't decided whether to just leave this junction (does anything really use it?), delete it, or delete it AND create a new one pointing to D:\XXXData\Documents.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
ZooStorm
OS
W7 x86
CPU
i3-3240
Motherboard
GigaByte H61M-DS2-DVI
Memory
4GB
Hard Drives
Western Digital 1TB
Antivirus
Avast
Browser
Chrome
I've just come across the exact same situation and I can confirm that it is left over when you do a Move of My Documents. I have tried it several times (after repeatedly doing image restores). I assume it is something that Microsoft never addressed.

My guess is that the vast majority of folks that do such a Move are never aware of the redundant Junction. Unless they go into C:\Users\XXX (with "Hide protected operating system files" disabled) and click on the My Documents, you don't tend to come across it. And unless they run into issues with software accessing the junction via hard coded paths in software it will never become an issue.

At the moment I haven't decided whether to just leave this junction (does anything really use it?), delete it, or delete it AND create a new one pointing to D:\XXXData\Documents.
Bad written software uses it! Software meant for winxp
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
ACER ASPIRE 5742G
OS
Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
CPU
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
Motherboard
Acer Aspire 5742G
Memory
4,00 GB
Graphics Card(s)
ATI Mobility Radeon HD 5400 Series
Sound Card
(1) AMD High Definition Audio Device (2) Realtek High Defi
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
WDC WD5000BEVT-22ZAT0
A bit more info. on a couple of aspects:-

I've also just done another image restore and tried moving the Documents folder to another path on the C: partition to see whether the My Documents junction would be updated in such a case (as I wondered whether it was just not updated if the Move was to another drive / partition). No joy - same result as before.

Also, the original Documents folder contained junctions pointing back at My Music, My Pictures and My Videos. These are lost during the Move.
 
Last edited:

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
ZooStorm
OS
W7 x86
CPU
i3-3240
Motherboard
GigaByte H61M-DS2-DVI
Memory
4GB
Hard Drives
Western Digital 1TB
Antivirus
Avast
Browser
Chrome
You made an interesting final observation there - I just confirmed that for a different user on my system, one I rarely use which takes up very little space and which I simply left on the C partition, there are indeed hidden junctions in My Documents for My Music, My Pictures and My Videos just as you describe. Those were not recreated in the new location when My Documents was moved on my system, either.

This looks like another "junction bug" when moving My Documents. I have fortunately never had any problem with their absence.

The procedure Kaktussoft described to fix the My Documents junction worked for me (albeit with the one permissions problem I mentioned that I worked around and described), and I've never had any problems since.

So I'd recommend it if you want to clean up as I did.

I suppose I should also now add the 3 missing junctions you just discovered. I would imagine adding those junctions would be absolutely harmless - if software is looking there, they'll find the junctions, and if not, they'll just sit there harmlessly.

Good luck, and thanks for confirming the problem. I never tried to confirm for myself whether it was a bug or a mistake that I made, and you've made it clear now that it's a Microsoft bug. And thanks for adding more to the overall information about this.
 
Last edited:

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
Good to hear your feedback.

I also found this in Windows 7 Inside Out:

"If you move any or all of your personal data folders, watch out for one gotcha: the Windows Search index includes the original profile locations by default, but it doesn’t pay attention when you relocate. To ensure that the files in your relocated folders show up, you must add the new locations to the list of folders that the search engine indexes."
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
ZooStorm
OS
W7 x86
CPU
i3-3240
Motherboard
GigaByte H61M-DS2-DVI
Memory
4GB
Hard Drives
Western Digital 1TB
Antivirus
Avast
Browser
Chrome
After partitioning my system to create a D:\ drive and moving my main user files there, I added D:\ to the indexed locations. The indexing options are confusing. The tutorial here shows AppData;AppData are excluded (meaning the AppData of 2 different users). Maybe it's possible to hunt the registry to figure out WHICH AppData are being excluded, but the basic indexing dialog gives no way to figure this out. At one time I figured it out and got it to index my most important AppData. (People can debate whether or not that's a good idea.) The registry entries used by search are very convoluted, not even clear what is an exclude vs. an include, while the GUI's display of what's excluded only shows the final part of a folder path... horrible. HORRIBLE. And then, search is much more difficult to use than XP search (though, when it works, much faster). Overall - hate it! You need to keep an expert tutorial open at all times to use search for anything more than the most obvious searches.
 

My Computer

Computer Manufacturer/Model Number
Dell Vostro 3500
OS
Windows 7 Professional SP1 - 32 bit
CPU
Intel i3 M 370 2.4 Ghz
Memory
4.00 GB
Monitor(s) Displays
External: Dell 19" 1901FP; Notebook: Dell 15" nightmare
Hard Drives
WDC internal 320 GB
Seagate FreeAgent Go USB 2.0 500 GB (2 of these)
Back
Top