Hello, I am new to vbs and I am trying to copy 'multiple folders' out of a folder called 'voice profiles' into the 'my documents' folder.

I've tried this script I wrote and haven't got the results I've wanted.

dim filesys, tempFile, readFile, fileText, fileVer

On Error Resume Next

'' Open the FileSystemObject
set filesys = CreateObject("Scripting.FileSystemObject")


   if (filesys.FileExists("C:\MRPComp") = True) Then
   filesys.CopyFolder "L:\Voice Profiles\*", "c:\Documents and Settings\%USERNAME%\My Documents\"
   end if

Try and change the following -

filesys.CopyFolder "L:\Voice Profiles\*", "c:\Documents and Settings\%USERNAME%\My Documents\"

to

filesys.CopyFolder "L:\Voice Profiles\*", "c:\%homepath%\My Documents\"

I tried what you suggested and it still didn't copy the folders in Voice profiles over. I thought the path was fine.. just not sure if I'm coding it right. I want all the folders in the 'voice profiles' folder to copy into 'my documents'.

Maybe I'm not explaining it well. I have computers that can access L:\ Drive on the network. I'm trying to Copy all the Folders in L:\Voice Profiles\ to the user's My Documents Folder on C: Drive on their computer. Here my code a bit different from before. Everytime I run the script it doesn't put those folders in there My documents folder.

Dim filesys, StrSourceFolder, StrDestinationFolder
   Set filesys = CreateObject("Scripting.FileSystemObject")

   StrSourcefolder = "L:\Voice Profiles\*"
   StrDestinationFolder = "c:\Documents and Settings\%USERNAME%\My Documents"
   
   if (filesys.FileExists("C:\MRPComp") = True) Then
   filesys.CopyFolder StrSourceFolder, StrDestinationFolder, True
   end if

The part I found earlier on will restrict you in Vista and win 7. I believe you can use the part %homepath%, which refers to your documents on XP, Vista and 7.

It does however seems that you have to use "copyfolder" AND ""copyfile"

Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.CopyFolder "\\L:\voiceprofiles\*", "c:%homepath%\My Documents\" ,True 'Had to remove the slash after c:... dummy me. Also, before L: the 2 backslashes for network access it seems.
filesys.CopyFile "\\L:\voiceprofiles\*", "c:%homepath%\My Documents\", True
MsgBox"BackUp completed, Goodbye", vbInformation, "Script Informer"

I hope this helped.:twisted:

Thanks! It works!

Cool, it's a pleasure.

who can assist to help me write a simple stock control system

Cool, it's a pleasure.

tahe problem is am new in the site and a don know how to use it so well

We are now getting there ramaliah. You still have to open your own thread though. Scroll right to the top of this page. You will see that there are headings, "Editorial", "Hardware & Software", and "Software".

HOLD your mouse over Software. a Popup will show with all of the menus under Software.
Select Visual Basic 4/5/6 by clicking on it.

Once the page opens, just below these headings you were before, you will see a heading "Want to start a new topic discussion? ... Click Here to Start a New Thread"

This will open a new post box that you can type your question in to. Again, please tell us what datbase you are using (Access, Sql, MySql etc.), what you need and most IMPORTANT, what have you coded so far.

I'll follow your new thread as soon as it is posted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.