Invalid junction after moving "My Documents"?

Page 1 of 2 12 LastLast

  1. if7
    Posts : 9
    Windows 7 Professional SP1 - 32 bit
       #1

    Invalid junction after moving "My Documents"?


    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


  2. if7
    Posts : 9
    Windows 7 Professional SP1 - 32 bit
    Thread Starter
       #2

    Anyone have any thoughts on this issue?
      My Computer


  3. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #3

    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


  4. if7
    Posts : 9
    Windows 7 Professional SP1 - 32 bit
    Thread Starter
       #4

    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


  5. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #5

    (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


  6. if7
    Posts : 9
    Windows 7 Professional SP1 - 32 bit
    Thread Starter
       #6

    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


  7. if7
    Posts : 9
    Windows 7 Professional SP1 - 32 bit
    Thread Starter
       #7

    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


  8. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #8

    "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


  9. if7
    Posts : 9
    Windows 7 Professional SP1 - 32 bit
    Thread Starter
       #9

    Thanks! I will follow these instructions. I appreciate your help.
      My Computer


  10. if7
    Posts : 9
    Windows 7 Professional SP1 - 32 bit
    Thread Starter
       #10

    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


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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 18:24.
Find Us