![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | 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 |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: VBScript problems *** 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 > ? *** 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 *** 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 ? *** 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? *** 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 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 |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: VBScript problems Sudhakar wrote: 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 ? 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 the data in the folders, you might determine you only want to copy newer and changed files which would dramatically reduce your backup times. You can use the /XO switch for that. Hope that helps. Regards, Mark D. MacLachlan -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| CSS and VBscript | VB Script | |||
| VBscript Help | VB Script | |||
| How to do No hang up VBScript (nohup for VBScript) | VB Script | |||
| Powershell Wrapper Script Problems - Trying to Call PowershellExchange 2007 Commands from Secondary Language (Like VBScript) | PowerShell | |||
| vbscript and HTA help | VB Script | |||