/build/static/layout/Breadcrumb_cap_w.png

VBscript to search in folders and copy to other folder

Hi,

Can anyone please help to provide a script to search for a file in some folders and then copy to other folder.

For example ..search for winword.exe in below mentioned folder...

C:\Program Files\Microsoft Office\Office

C:\ Program Files\Microsoft Office\Office11

C: Program Files\Microsoft Office\Office12

And once winword.exe is found ..copy it to below folder:

C: Program Files\Microsoft Office\Office14

Many Thanks,
DJ

PS: Ian please ingore this message.... I know I am expecting this help in free...I believe someone will be able to help...[8D]

0 Comments   [ + ] Show comments

Answers (7)

Posted by: cygan 13 years ago
Fifth Degree Brown Belt
2

Set oShell = CreateObject("Wscript.Shell")
prgFile = oShell.ExpandEnvironmentStrings("%PROGRAMFILES%")
CtxFile=prgFile & "\Microsoft Office\Office\winword.exe"
CtxFile1=prgFile & "\Microsoft Office\Office11\winword.exe"
CtxFile2=prgFile & "\Microsoft Office\Office12\winword.exe"
DestinationFileLocation=prgFile & "\Microsoft Office\Office14\"

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(ctxFile) And objFSO.FileExists(ctxFile1) And objFSO.FileExists(ctxFile2) Then

objFSO.CopyFile ctxFile,DestinationFileLocation
OverwriteExisting

objFSO.CopyFile ctxFile1,DestinationFileLocation
OverwriteExisting


objFSO.CopyFile ctxFile2,DestinationFileLocation
OverwriteExisting

End If
Set objFSO = nothing




play around with this ,I have not tested this in any shape or form
really basic but this can give you some clues
Posted by: anonymous_9363 13 years ago
Red Belt
0
Fair dos...it might not be part of an install? But then, wouldn't the poster have used the 'Scripting' forum?
Posted by: anonymous_9363 13 years ago
Red Belt
0
It's not so much that you want it for free but that you seem incapable of using a search engine. There must be a quadzillion example scripts showing how to recursively search a folder for a file.
Posted by: djain3 13 years ago
Second Degree Blue Belt
0
Any help please...
Posted by: cygan 13 years ago
Fifth Degree Brown Belt
0
all you need is the filesystemobject methods
have a look at this LINK
Posted by: djain3 13 years ago
Second Degree Blue Belt
0
Many Thanks Cygan....I have given you score for your help...[:)]
Posted by: aogilmor 13 years ago
9th Degree Black Belt
0
c'mon now vb you can't expect supermember djain3 to use a search engine
and, I'm sure that there must be a legitimate reason for using vbscript instead of the standard windows installer tables! [:D]
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ