Solved

VB6 - folder copy dependant on username

Posted on 2004-09-20
5
175 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 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro: print each sheet to pdf using ExportAsFixedFormat 11 48
VBA filters 2 61
Recommendation vb6 to vb.net or others 14 150
VB 6 error 5 in windows 10 but not in XP 7 56
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

810 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