Need urgent Help iIn coping a folder using vb scipt

Hi people,
I have been tryin to copy a folder using vb script

dim aFileObj,srcfile,desfile,ws,I,IsOverWrite,SysRoot,srcdir,desdir,DirFlag

dim files(2)



set ws = CreateObject("Wscript.Shell")
'Getting System Root i.e C:\
SysRoot = ws.ExpandEnvironmentStrings("%WinDir%")


srcdir= ws.CurrentDirectory & "\GWMCONFIG"
msgbox srcdir
desdir= SysRoot & "Program Files\Kofax\ImgCtls"
msgbox desdir


set aFileObj=CreateObject("Scripting.FilesystemObject")

if DirFlag then
if not aFileObj.FolderExists(desdir) then
aFileObj.CreateFolder desdir
end if
end if

for I=0 to ubound(files)

if aFileObj.FileExists(srcdir & files(I)) then
on error resume next
aFileObj.CopyFile (srcdir & files(I)),(desdir & files(I)),IsOverWrite
msgbox aFileObj
end if


set aFileObj=Nothing
set ws=Nothing

The script has no errors yet it is nt working....Please help

0 Comments   [ + ] Show comments

Answers (4)

Posted by: Jsaylor 12 years ago
Second Degree Blue Belt
srcdir resolves to: C:\program files\Kofax\ImgCtls

Files(0) resolves to: c.bat

srcdir & files(0) resolves to: C:\program files\Kofax\imgctlsc.bat

I'm sure you can figure out the rest from there.
Posted by: anonymous_9363 12 years ago
Red Belt
Is there a reason for NOT using the FileSystemObject object's CopyFolder method?
Posted by: Jsaylor 12 years ago
Second Degree Blue Belt
Yeah, I tried to stay away from those kinds of questions. That's a dangerous, mentally damaging path you're traveling down there Ian.
Posted by: AngelD 12 years ago
Red Belt
Or the OP needs to be consistence!

The question says one thing and the posted script does something else.
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