• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

VB6 - folder copy dependant on username

I'm writing a small program to help facilitate migration of users as well as learn more about VB6.  I would like to copy the favorites folder from a Windows 200 Pro user account and copy it into another folder named after the user.
What I have so far is copying the all of the folders under the username instead of just the Favorites folder.  

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "c:\documents and settings\" & strUser & "\Favorites\", "c:\Migration\" & strUser

The folders structure "C:\Migration\User" is already in place from an earlier event.

Any guidance would be appreciated.
0
acksis
Asked:
acksis
  • 3
  • 2
1 Solution
 
jimbobmcgeeCommented:
Try using
 "c:\documents and settings\" & strUser & "Favorites"    <---- no '\' at the end...
0
 
acksisAuthor Commented:
>>Try using
>> "c:\documents and settings\" & strUser & "Favorites"    <---- no '\' at the end...

No good - same results
0
 
jimbobmcgeeCommented:
That's interesting; your code (without the extra '\') worked for me...

I changed it to the following, to meet my network spec
    strUser = InputBox("Enter username")
    strDSFolder = "d:\documents and settings"
    strFolderToCopy = "favorites"
   
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFolder strDSFolder & "\" & strUser & "\" & strFolderToCopy, "c:\Migration\" & strUser

and it worked fine.

Very odd...

You are an Administrator of your machine?
0
 
acksisAuthor Commented:
I tried to modify my code to match yours and got the same results but when I actually did a copy and paste it worked.  I'm not really sure what the problem was.  I would suspect a typo but the code posted in my question is also copied and pasted.

Regardless, your solution worked - thanks for the help.
0
 
jimbobmcgeeCommented:
No problem.  If you ever find out why yours didn't work, let me know...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now