|
VBScript problems I want to copy the contents of "SourceDir" directory to "TargetDir" directory
in
Windows XP,
say,
TargetDir = C:\SAS
SourceDir = C:\SASLatest
BackupDir = C:\SASBackup
Both the above directories contains files and subfolders and sub-subfolders
The approach I would follow is,
1) Take a backup of TargetDir
2) Empty the TargetDir
3) Copy the contents of SourceDir to TargetDir
4) If copy is successful
{
delete the BackupDir
}
else If copy is not successfull
{
restore the sourceDir i.i. copy the contents of BackupDir to SourceDir
}
I wrote an vbscript for the above operation ?
My doubts:
1) Can I use FileSystemObject.CopyFolder method for copying files and
folders recursively ?
sometimes, I get permission denied error, i rectified and i still suspect
whether I'll get that error, will the CopyFolder method of FSO is reliable ?
Can I use , XCOPY cmd of DOS using to copy files and folders instead ?
Please anybody suggest which one is best
2) Does the VBscript has any main() , I just declare the variables using Dim
statement and then immediately start the processing, Is that correct or I
should have any main() procedure ?
3) I need to call this VBScript from inside a C++ program. I thought of
ShellExecute API to call the VBScript. But i was told that, the "open" verb
for the vbsript might be disabled , so I need to call the WSCript.exe
explicitly to call the VBScript.
How i enable the open verb for VBScript so thatit runs without any problem ?
How to obtain the path for wscript.exe in the PC or how to make it as the
default engine for VBScript?
4) when the CopyFolder method is used, How to get a copy progress bar ?
I know that it is available in
Shell.Application.Namespace object, CopyHere method
I used likem
Dim objShell
Set objShell = WScript.CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace("C:\targetFolder")
objFolder.CopyHere "C:\SourceFolder",16
---- to display the progress bar while copying, bu the problem here is that ,
"targetfolder " itself is copied under C:\SourceFolder, but i wnat to copy
the contents of C:\targetfolder to C:\sourcefolder, thats why I dint opted
for CopyHere, how to achiev this in CopyHere method
thanks,
Sudhakar |