954,582 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

VBS Script Question

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.

[code]
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

[icode]

cwestern
Newbie Poster
5 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

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\"
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

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'.

cwestern
Newbie Poster
5 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

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
cwestern
Newbie Poster
5 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

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:

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

Thanks! It works!

cwestern
Newbie Poster
5 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

Cool, it's a pleasure.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

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

ramaliah
Newbie Poster
4 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 
Cool, it's a pleasure.


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

ramaliah
Newbie Poster
4 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

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.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: