PDA

View Full Version : Sleeper: Copy a file



onlines
01-13-2009, 01:12 PM
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FolderExists(MTDdir) Then
Set objFolder = objFSO.GetFolder(MTDdir)
WScript.Echo MTDdir & " already exists "
else
Set objFolder = objFSO.CreateFolder(MTDdir)
WScript.Echo "Created " & MTDdir
objFSO.CopyFile templatePath,MTDdir
WScript.Echo "Copied to " & MTDdir
end if

Above is code which should copy file located in "...\MTD Template\Template.xls" to "...\Coding Phase\MTD" (the dots simply represent truncated path for security purposes)

It will create the folder, and will do nothing if it already exists, but when it copies... it says, "Copied to..." but there is nothing in the folder.

Any ideas?

EDIT : i have tried



set wshell = WScript.CreateObject("WScript.Shell")
objFSO.CopyFile templatePath,MTDdir
wshell.Run chr(34) & MTDdir & chr(34)


And now i get permission denied? Is there any way when the folder creates that i can remove "Read Only" restriction on the folder creation?

thank you!