Script to change Profile folders's locations


  1. Posts : 13
    Windows 7 64 bit - Server 2008 R2 (64bit)
       #1

    Script to change Profile folders's locations


    Hi,

    At my home, I have a Server 2008 R2 domain with all clients running Win 7. I personally do not like storing user documents and files in the C\User folder as it has a lot of other profile junk in it. I simply create a folder called C\Data and create MyDocs, Music, Download, Videos etc folders in it. After that I manually redirect each type of folders from the current location to these new locations. This allows me to easily backup the required data rather than all the stuff that I don't care for. When profiles get bloated, I simply delete them and then redirect folders from the new profile again. All the data remains in the C:\Data.

    All this redirecting can get tedious. I am looking for a script (vb script, batch file, reg file, power shell script) that I can have pre-configured with locations and simply run when I need redirection.

    Any help is appreciated.

    Thanks
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hi DJ...,

    Before any script can be made, I'll need you to provide more details about the task you describe. Namely, would you be able to outline the process that you'd take normally; that is, how exactly would you achieve your task the "tedious", manual way?
      My Computer


  3. Posts : 13
    Windows 7 64 bit - Server 2008 R2 (64bit)
    Thread Starter
       #3

    Hi,

    I create the following folders manually.

    C:\Data\User1\MyDocs
    C:\Data\User1\Music
    C:\Data\User1\Videos
    C:\Data\User1\Pics
    C:\Data\User1\Download
    C:\Data\User1\Favs

    Then manually redirect the corresponding folders from C:\Users\User1\.

    This seems like an easy enough task if it is one off but if I create a new user, then I have to do this to every PC/Laptop that user will use. Also, about a month or so ago, I had to rebuild my server which mean old user profiles on the user PCs were no longer valid when logging on to the domain. For this reason, I had to do this for each user for every PC/Laptop.

    If I can script this, then I can easily modify the script for location and user and simply run it.

    Thanks.
      My Computer


  4. Posts : 543
    Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
       #4

    I have several great books from which, after many hours of trial and error testing, I have learned how to write my own scripts. Would you be interested in learning the process of creating your own scripts which will meet your precise needs?
      My Computer


  5. Posts : 13
    Windows 7 64 bit - Server 2008 R2 (64bit)
    Thread Starter
       #5

    I don't mind the learning process. I believe I am pretty good with batch and reg files (yep, oldie). I can work with some VB scripts as well. However, I simply do not know where these locations are stored.

    (I have no practical experience with Power Shell)
      My Computer


  6. Posts : 13
    Windows 7 64 bit - Server 2008 R2 (64bit)
    Thread Starter
       #6

    I should clarify that I know the location of the folders but I do not know where Windows is storing the information that tell you where these folders are. If I can find that out, then I can probably script it.

    I thought about using AutoIT to do this and perhaps use Send Keys but that seems a but too dodgy solution to me.
      My Computer


  7. Posts : 13
    Windows 7 64 bit - Server 2008 R2 (64bit)
    Thread Starter
       #7

    OK, I think I found the location in the registry.

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

    All of the user folders' locations are listed here. I can now create a modified reg file easily.

    Thanks.
      My Computer


  8. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #8

    DJDJDJDJ said:
    I should clarify that I know the location of the folders but I do not know where Windows is storing the information that tell you where these folders are.
    DJDJDJDJ said:
    OK, I think I found the location in the registry.

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
    Very close. This registry key exists only for backwards compatibility, and changing values under this key will have no effect on the locations of users' folders. Windows defines user folders under the following registry key,
    Code:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
    I'm not fully clear on your intentions, DJ, but I doubt a reg file is fit for the task--it is not a script--and if you change data under either of the mentioned keys, do know that you'll still have to manually move items in C:\Users\User1 to the new location C:\Data\User1.

    On any note, if you require assistance with a script or reg file, feel free to post any snippets here for review.
      My Computer


  9. Posts : 13
    Windows 7 64 bit - Server 2008 R2 (64bit)
    Thread Starter
       #9

    Thank you very much for this.

    I think reg file will work well for me.

    I do not need to move any data files. They will always be in C:\Data\*. I simply need to point any new user profiles to folders in this location. This allows me to have all the user files in location without any system or application generated files.

    For example, C:\Users\%username%\ folder contains folders for appdata, searches etc. I really don't care for these folders. iTunes etc. create a log of garbage there. Even Microsoft folder can contain a ton of files. They are necessary for running apps but I don't want to worry about backing them up. By moving the important actual content folders, I can keep a clean data folder for backups.

    I am aware that reg file will not move files. I don't really need to move files. If it is a new profile, it is not going to have any data files to move anyway. If I am relocating an existing profile, then I can manually move the data files as it will be a one-off relocation.

    I will create a batch file that will check for the existence of the destination folders and create them if necessary. It can then merge the reg file.



    Pyprohly said:
    DJDJDJDJ said:
    I should clarify that I know the location of the folders but I do not know where Windows is storing the information that tell you where these folders are.
    DJDJDJDJ said:
    OK, I think I found the location in the registry.

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
    Very close. This registry key exists only for backwards compatibility, and changing values under this key will have no effect on the locations of users' folders. Windows defines user folders under the following registry key,
    Code:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
    I'm not fully clear on your intentions, DJ, but I doubt a reg file is fit for the task--it is not a script--and if you change data under either of the mentioned keys, do know that you'll still have to manually move items in C:\Users\User1 to the new location C:\Data\User1.

    On any note, if you require assistance with a script or reg file, feel free to post any snippets here for review.
      My Computer


 

  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 03:03.
Find Us