Solved

VB6 - folder copy dependant on username

Posted on 2004-09-20
5
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 100 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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
Course of the Month6 days, 11 hours left to enroll

634 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