Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB6 - folder copy dependant on username

Posted on 2004-09-20
5
Medium Priority
?
180 Views
Last Modified: 2010-05-02
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
Comment
Question by:acksis
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12112821
Try using
 "c:\documents and settings\" & strUser & "Favorites"    <---- no '\' at the end...
0
 

Author Comment

by:acksis
ID: 12113276
>>Try using
>> "c:\documents and settings\" & strUser & "Favorites"    <---- no '\' at the end...

No good - same results
0
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 400 total points
ID: 12113997
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
 

Author Comment

by:acksis
ID: 12115251
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
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12121094
No problem.  If you ever find out why yours didn't work, let me know...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question