*** See below.
"Sudhakar" <Sudhakar@xxxxxx> wrote in message
news:CB30BECB-E0DA-4B65-AC31-4AC0AB8285DC@xxxxxx
Quote:
>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
> ?
*** The File System Object is totally reliable. If you get permission errors
*** then it's either because of a permission issue or because of an error
*** in your program.
Quote:
> Can I use , XCOPY cmd of DOS using to copy files and folders instead ?
> Please anybody suggest which one is best
*** Copying files and folders is a standard administrator's task for
*** which there are fully developed console commands with a rich
*** set of switches. Using xcopy.exe or robocopy.exe requires
*** about one tenth of the code that the equivalent VB Script does.
*** Note, by the way, that DOS is a legacy operating system that
*** was first introduced in about 1978 and was last used with Windows
*** ME. It is not available under WinXP. The Command Console may
*** be black but inside it is radically different from DOS.
Quote:
> 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 ?
*** You don't need a main() procedure in VB Script. Have a look at
*** the examples you see in this newsgroup!
Quote:
>
> 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?
*** If you want to write robust applications then you should invoke
*** your VB Scripts like so:
*** cscript //nologo c:\Scripts\SomeScript.vbs
*** or maybe
*** wscript //nologo c:\Scripts\SomeScript.vbs
Quote:
> 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
*** Have a look here:
http://www.microsoft.com/technet/scr....mspx?mfr=true http://www.microsoft.com/technet/scr...6/hey1010.mspx Quote:
> 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