I am facing some problem copying a .exe file from a source folder to Destination folder.
I'd appriciate help.
Below is the Script i am trying.
parentPath = "Q:\\WRKGRP\\StimSiteDev\\Disks\\PET\\PET_R_200909 02.1"
destinationPath = "C:\\Documents and Settings\\Administrator\\Desktop\\PETInstall";
if(Utilities.DirectoryExists(parentPath) && Utilities.FileExists(parentPath+"\\"+"PET*.exe"))
BuiltIn.CopyFiles(parentPath ,destinationPath , "")
a = slPacker.GetFileListFromFolder(destinationPath)
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileObj = fso.GetFile('"'+"C:\\Documents and Settings\\Administrator\\Desktop\\PETInstall\\"+a+ '"');
fileObj.Copy("C:\\Documents and Settings\\Administrator\\Desktop\\PETInstall\\PETI nstall.exe");
Could you clarify what the problem is that you're experiencing?
On a quick inspection, I think your problem may be in the call to set a to a value. The GetFileListFromFolder could, potentially, return a string containing multiple filenames and folder names. So, putting that in as part of your call to fso.GetFile could result in the filename as being incorrect.
You might want to use something like aqFileSystem.FindFiles and then iterate through each file in the array that is returned and copy those files to your destination.
Here's an example in DelphiScript where I'm doing something similar.
<font class="small">Code:</font><hr /><pre>
lFolderList := aqFileSystem.FindFolders(lSourcePath + '\Gateway.Webstore\', '*.*');
for i := 0 to (lFolderList.Count - 1) do
lFolderList.Item[i].Copy(WebstoreRootPath + 'Webstore\', FALSE);</pre><hr />
In addition to Robert'a answer, please note that the methods of the Utilities and BuiltIn objects are obsolete. So, I suggest that you use the corresponding methods of the aqFileSystem, aqFile, aqFileInfo and aqFolderInfo objects. Please see the "aqFileSystem Object", "aqFile Object", "aqFileInfo Object" and "aqFolderInfo Object" help topics for lists of available methods.