Ben.Hahlen Posted May 18, 2005 Share Posted May 18, 2005 Hey everyone,I was wondering whether it would be possible to set the My Documents folder through a batch file, in which the batch-file recognizes the My Documents folder by itself.I think it should be something like what we use to set the %CDROM% variable, but since I have no clue how to make those kind of things, I'm sort of counting on you guys .Example:The My Documents folder resides on a partition (I:\My Documents). The batch file would look for a file in the My Documents folder (ie: my.docs), from which it then would set a variable %documents% (or sth) that can be used to have the necessary registry-entries be made, so that it is not necessary to do that after the install anymore.I know this is possible through a registry-entry, but if you're installing on a different pc, the documents folder might be on a different drive, in a different folder, etc, which makes it inconvenient.Thanks in advance for the replies.Greetz,Ben. Link to comment Share on other sites More sharing options...
Gnome Posted May 18, 2005 Share Posted May 18, 2005 Hi Ben.Hahlen how's it going?The I:\My Documents ... should this be your All users My Documents or Current User My Documents...To make it abit clearer i'll use the example of Default Windows XP:Usually Default Windows XP All Users Folder would be: c:\Documents and Settings\All Users\DocumentsAnd your current user would be:c:\Documents and Settings\<CURRENT USER>\My DocumentsEDIT: NM Link to comment Share on other sites More sharing options...
Ben.Hahlen Posted May 18, 2005 Author Share Posted May 18, 2005 Hey Gnome,I'm fine, how are you? How's your project going? Anyhow, it would be the user-My Docs folder.So the:C:\Documents and Settings\<current user>\My DocumentsThanks for your help . Link to comment Share on other sites More sharing options...
Gnome Posted May 18, 2005 Share Posted May 18, 2005 EDIT: Removed because I didn't understand correctly Link to comment Share on other sites More sharing options...
Ben.Hahlen Posted May 18, 2005 Author Share Posted May 18, 2005 Thanks for your answer Gnome, but it's not really what I meant.I'll try to explain better.I know that you can set user shell folders through these registry keys:[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]"Personal"="I:\\My Documents"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]"My Pictures"="I:\\My Documents\\My Pictures"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]"My Music"="I:\\My Documents\\My Music"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]"My Video"="I:\\My Documents\\My Video's"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]"Favorites"="I:\\My Documents\\Favorites"[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer]"Download Directory"="I:\\My Documents\\My Downloads"Now, what I would like to do, is to have a batch-file (or a program) search for the Documents folder, and then set automatically set these registry keys.I think it would have to be sth as being done with the %CDROM% variable when using RunOnceEx from cd, ie:FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\CD.txt SET CDROM=%%i:Only here, it should look for a file (ie: my.docs) so that it can change the My Documents folder to that folder.So in a nutshell, it would be a program that would look for a file and then set the user shell folders accordingly.Would this be possible? Link to comment Share on other sites More sharing options...
Solid as a rock Posted May 18, 2005 Share Posted May 18, 2005 i am interested in the knowhow too *bookmarked* Link to comment Share on other sites More sharing options...
Yzöwl Posted May 18, 2005 Share Posted May 18, 2005 You chould be able to create a batch file that willsearch drives, (as in the CDROM example)look for a folder name ending with Documentssearch in this folder for a file, (probably desktop.ini as this will have information unique to the folder)When a match is found add the information to the User Shell Folders registry key Link to comment Share on other sites More sharing options...
Ben.Hahlen Posted May 18, 2005 Author Share Posted May 18, 2005 You chould be able to create a batch file that willsearch drives, (as in the CDROM example)look for a folder name ending with Documentssearch in this folder for a file, (probably desktop.ini as this will have information unique to the folder)When a match is found add the information to the User Shell Folders registry key<{POST_SNAPBACK}>The problems are though:1. Some users have their documents in the root of a partition2. I don't know how to create such a batch Link to comment Share on other sites More sharing options...
Marthax Posted May 18, 2005 Share Posted May 18, 2005 You could use the %UserProfile% variable to have a batch file search in My Documents. Although this will only work if you have one account, it should be able accomplish the thing you want to do. Link to comment Share on other sites More sharing options...
Yzöwl Posted May 18, 2005 Share Posted May 18, 2005 You could use the %UserProfile% variable to have a batch file search in My Documents. Although this will only work if you have one account, it should be able accomplish the thing you want to do.<{POST_SNAPBACK}>you would probably need to use %username% in that scenario, since the profile directory will not have the redirected Documents directory.Also I still think that the desktop.ini wil be the most common denominator, reagardless of any user defined folder name. Although in my case I don't have any, hence the reason why I haven't wrote up a batch for testing yet. Link to comment Share on other sites More sharing options...
Ben.Hahlen Posted May 18, 2005 Author Share Posted May 18, 2005 The %username% will also not be used (I think), since, as you said, the Documents directory has been redirected to a different partition/drive.I think for a denominator I would use something like "my.doc", most users have a documents directory anyway before a reinstall, and it's not that hard to create a file. Furhtermore, the desktop.ini is a "super-hidden" file, so I think it would be hard to find it in the first place. Another thing is: desktop.ini files are scattered throughout your folders, especially if you've customized your folders with icons (like me). Link to comment Share on other sites More sharing options...
Marthax Posted May 19, 2005 Share Posted May 19, 2005 I really don't agree Ben.Hahlen. Does it matter if you create My Documents on C:, D:, E: or any other drive? %USERPROFILE%\My Documents means that Windows has the present location of My Documents registered and knows where My Documents is so there won't be any problem when you search for the location of it. Link to comment Share on other sites More sharing options...
Yzöwl Posted May 19, 2005 Share Posted May 19, 2005 Let me try to explain the idea, as I understand it, from the original questioner.You are creating an unattended install onto a PC, this PC previously has had the OS installed, but had redirected the location of My Documents, for at least one user to another drive /partition.When the new install is invoked, the registry of that install will not have the path of the existing Documents directory, only the default %userprofile%\My Documents.Now I know we could put the hard coded data into a redirection script at T12, but that would mean every PC we used the CD on would need to have My Documents in the same drive\path\name.What is requested is a script which will scan all drives, from cmdlines.txt and look for a common 'tagfile' which absolutely guarantees the location of the existing data. This location can then be applied to the user shell folders registry key.This would be easy if everyone used the %username% in their redirected documents folder name, and also set up the new install with the same user names, or if at the very least, the desktop.ini was unaltered by replacing folder icons etc. Using the %username% is a perfect solution when the folder is originally redirected, because all users will still have their own unique folder named <username> Documents. Then as I said in my original assessment, your script would just have to search drives for a folder named "%username% Documents", and add the match to the registry.The %username% idea would be my generic solution, which would cover all PCs I have to work on, but will not suit everyone because people have all customized their folder and /or location differently.I cannot think of a 'one size fits all' solution, other than prompting the user for the location in the script. Link to comment Share on other sites More sharing options...
Ben.Hahlen Posted May 19, 2005 Author Share Posted May 19, 2005 Let me try to explain the idea, as I understand it, from the original questioner.You are creating an unattended install onto a PC, this PC previously has had the OS installed, but had redirected the location of My Documents, for at least one user to another drive /partition.When the new install is invoked, the registry of that install will not have the path of the existing Documents directory, only the default %userprofile%\My Documents.Now I know we could put the hard coded data into a redirection script at T12, but that would mean every PC we used the CD on would need to have My Documents in the same drive\path\name.What is requested is a script which will scan all drives, from cmdlines.txt and look for a common 'tagfile' which absolutely guarantees the location of the existing data. This location can then be applied to the user shell folders registry key.This would be easy if everyone used the %username% in their redirected documents folder name, and also set up the new install with the same user names, or if at the very least, the desktop.ini was unaltered by replacing folder icons etc. Using the %username% is a perfect solution when the folder is originally redirected, because all users will still have their own unique folder named <username> Documents. Then as I said in my original assessment, your script would just have to search drives for a folder named "%username% Documents", and add the match to the registry.The %username% idea would be my generic solution, which would cover all PCs I have to work on, but will not suit everyone because people have all customized their folder and /or location differently.I cannot think of a 'one size fits all' solution, other than prompting the user for the location in the script.<{POST_SNAPBACK}>You've got it correct.It does not necessarily need to be run from cmdlines.txt though.As I indicated before, some users use the root of their partition as their Documents "folder", which would make the usage of %username% obsolete.As you said, prompting the user could be a good solution, but then it's almost the same as doing it after the install, manually. Link to comment Share on other sites More sharing options...
Ben.Hahlen Posted May 20, 2005 Author Share Posted May 20, 2005 Anyone with an idea/suggestion?I could really use this Thanks in advance for the help 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