radigast Posted May 15, 2008 Share Posted May 15, 2008 (edited) It's time to optimize/fix some changes in my old unattended script, and I am not quite sure how to approach this problem. Maybe you can help me.I typically install Windows XP on its own partition, and let it do its merry thing while all my other data is on another partition. As such, I always move the "My Documents" folder to another partition.Here's my question: how can I write a batch file that automatically detects what partition "My Documents" is located on, and permanently assign that location an environment variable of "%MyDocs%"?Thanks guys.--radigast Edited May 15, 2008 by radigast Link to comment Share on other sites More sharing options...
Martin H Posted May 15, 2008 Share Posted May 15, 2008 how can I write a batch file that automatically detects what partition "My Documents" is located on, and permanently assign that location an environment variable of "%MyDocs%"?Unless i'm misunderstanding your request, then this should do it :set MyDocs="%userprofile%\My Documents" Link to comment Share on other sites More sharing options...
Yzöwl Posted May 16, 2008 Share Posted May 16, 2008 My Documents will always be located at "%userprofile%\My Documents" until you move it elsewhere.I think what you are trying to ask for is to perform a search of a non-%systemdrive% non-removable disks for the Directory which was previously your My Documents location and re-assign appropriately.The biggest problems here would be that the directory before assigning it will be named %UserName%s Documents, not My Documents and if there were more than one user previously there may be several directories similar in nature.The easiest method of performing this for an English based OS is to search for a directory name ending in 'Documents' once you've located one do a search for its desktop.ini file and then verify that the line beginning 'owner=' matches the name of the user. Once you've done that write that location to the 'user shell folders' registry key. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now