Saturday, August 17, 2013

GitExtensions ContextMenuHandlers

Here is a thread about duplicated menu entries in GitExtensions Explorer handlers.

Saturday, August 3, 2013

Move User Profile Folder

I had to move my user profile folder to another drive (because I could'nt wait for gparted to move my data). I am using Windows 7 Professionnal (in French). Context :
  • Moved profile : ded
  • Current (old) profile path : c:\Users\ded
  • Future (new) profile path : D:\ded
Here is what I did :
  • Create an(other) admin account (for example: root)
  • Close current ded session
  • Create d:\ded
  • Fix d:\ded ACL (you would need to uncheck include parent security)
My profile folder security is :
  • Administrators : Full Control, recursively
  • System : Full Control, recursively
  • ded : Full Control, recursively
  • root : Full Control, recursively
  • HomeUsers : see below
(It seems that root what added automatically under the hood)

HomeUsers permissions are :
  • Traverse folder / execute file
  • List folder / read data
  • Read attributes
  • Read extended attributes
  • Read permissions
HomeUsers permissions only apply to this folder only (not sub-folders nor files). French translation :
  • Parcours du dossier/exécuter le fichier
  • Liste du dossier/lecture des données
  • Attributs de lecture
  • Lecture des attributs étendus
  • Autorisations de lecture
Let's continue :
  • Copy all files with robocopy (keep permissions, etc.)
robocopy c:\users\ded d:\ded /e /copyall /sl /xj /np /nfl /r:1
  • Restart robocopy to find what failed
robocopy c:\Users\ded d:\ded /e /copyall /sl /xj /np /nfl /ndl /r:1 /w:1 /x
In my case I only had problems with :
  • junctions (not handled by robocopy)
  • Some tmp files (ignored)
  • Cardspace files (access denied!)
  • Google drive folder (denied)
To find junctions run :
dir c:\users\%username% /al /s
I used the following script to create junctions in my new profile folder. *BEWARE !* This script is for a French O/S.
@echo off
:: é = ‚
:: è = Š
setlocal
set new_home=d:\%username%
call :mk_junction "Application Data" "AppData\Roaming"
call :mk_junction "Cookies" "AppData\Roaming\Microsoft\Windows\Cookies"
call :mk_junction "Local Settings" "AppData\Local"
call :mk_junction "Menu D‚marrer" "AppData\Roaming\Microsoft\Windows\Start Menu"
call :mk_junction "Mes documents" "Documents"
call :mk_junction "ModŠles" "AppData\Roaming\Microsoft\Windows\Templates"
call :mk_junction "Recent" "AppData\Roaming\Microsoft\Windows\Recent"
call :mk_junction "SendTo" "AppData\Roaming\Microsoft\Windows\SendTo"
call :mk_junction "Voisinage d'impression" "AppData\Roaming\Microsoft\Windows\Printer Shortcuts"
call :mk_junction "Voisinage r‚seau" "AppData\Roaming\Microsoft\Windows\Network Shortcuts"
call :mk_junction "AppData\Local\Application Data" "AppData\Local"
call :mk_junction "AppData\Local\Historique" "AppData\Local\Microsoft\Windows\History"
call :mk_junction "AppData\Local\Temporary Internet Files" "AppData\Local\Microsoft\Windows\Temporary Internet Files"
call :mk_junction "AppData\Roaming\Microsoft\Windows\Start Menu\Programmes" "AppData\Roaming\Microsoft\Windows\Start Menu\Programs"
call :mk_junction "Documents\Ma musique" "Music"
call :mk_junction "Documents\Mes images" "Pictures"
call :mk_junction "Documents\Mes vid‚os" "Videos"
endlocal
goto :eof

:mk_junction
set link=%1
set target=%2
set link="%new_home%\%link:~1,-1%"
set target="%new_home%\%target:~1,-1%"
echo %link% -^> %target%
if exist %link% (
  echo found %link%, skipped
  goto :eof
)
mklink /J %link% %target%
::icacls %link% /deny Everyone:(S,RD) /L
icacls %link% /deny "Tout le monde":(S,RD) /L
icacls %link% /setowner SYSTEM /L
attrib +H +S +I %link% /L
goto :eof
For cardspace files, I suspected a mismatch between Administrateurs (French, unknown group) and Administrators (English, valid group) accounts. I managed to move or copy the files with cygwin mv or cp. Afterwards, I just did *attrib +h* on cardspace folder and files (CardSpaceSP2.db and CardSpaceSP2.db.shadow).

I ignored Google Drive, Google recreate it automatically (it wouldn't use a copy of the original folder).

Final step :
move c:\users\ded c:\users\ded.old
mklink /j c:\users\ded d:\ded
And fix d:\ded permissions (same as above).

Now I reopen a session with ded users with my new user profile folder.

HTH