Jump to content

Recommended Posts

Posted (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 by radigast

Posted
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"

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...