Copyfile Error Handling
Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a vbscript error handling Full Time Job Ways to Get Help Expand Search Submit Close Search Login vbscript copyfile Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > MoveFile/CopyFile in VBS and error handling Want to Advertise Here? Solved MoveFile/CopyFile in VBS and error handling Posted on 2004-05-03 Visual Basic Classic 2 Verified Solutions 10 Comments 5,160 Views Last Modified: 2012-06-27 The MoveFile and CopyFile methods in VBS does not return a code specifiying if there was an error or not performing the call. What's the best way to know if a file was moved or copied? Doing a FileExists doesn't seem to guarantee that the file was copied completely. The files being copied are on a local PC and the destination is to an FTP server using WebDrive. Thanks. 0 Question by:halfondj Facebook Twitter LinkedIn Google LVL 28 Best Solution byvinnyd79 what about getting the filesize before the copy,then comparing it after: Dim GetFileSize1,GetFileSize2,objFSO,f,Fname1,Fname2 Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Fname1 Go to Solution 10 Comments LVL 53 Overall: Level 53 Visual Basic Classic 24 Message Expert Comment by:Dhaest2004-05-03 You can add the standard exception method to your program: private sub Start 'Begin of script On Error GoTo StandardErrorHandler ' All your functions, like movefile, ... exit sub StandardErrorHandler: msgbox "copy failed" end sub 0 LVL 4 Overall: Level 4 Visual Basic Classic 2 Message Expert Comment by:marper2004-05-03 try also If Len(Trim(Dir("yourpath\yourfile,vbNormal))> 0 Then 'File is there end if 0 Message Author Comment by:halfondj2004-05-03 I'm using VBS, not VB. It's my understanding that one can only use 'On Error Resume Next' in VBS. For a test, I've implemented the following code, but if I disconnected the mapped drive (the drive that was mapped via WebDrive) when the CopyFile was taking place, the CopyFile still returned successful, not unsuccessful. I need to ensure that the CopyFile/MoveFile returns unsuccessful, when in fact, the fi
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBscript: Verifying that a file has been completely copied/error handling up vote 0 down vote favorite 1 I am https://www.experts-exchange.com/questions/20976243/MoveFile-CopyFile-in-VBS-and-error-handling.html trying to add something to my script that will let me know if a file that I am copying has been fully copied. Basically I am zipping up a bunch of files and then sending them to a mapped drive on the network. Then I have my script deleting the files in the original location once they have been successfully copied over. The script works perfectly fine but I just need to http://stackoverflow.com/questions/11300070/vbscript-verifying-that-a-file-has-been-completely-copied-error-handling add in some error handling that will let me know if the copy was not completed successfully. I have never used any error handling in vbscript as I am only about a week into this so any help would be greatly appreciated. Let me know if I need to explain anything more in depth. My script can be found below: Option Explicit Dim sDirectoryPath, sDestinationPath, sOutputFilename, Shell, sFileExt, sFilePrefix shell = WScript.CreateObject("WScript.Shell") 'Specify Directory Path where files to be zipped are located 'Specify destination for zipped files 'Specify file extension name to look for 'Specify prefix of filename to look for sDirectoryPath = "C:\Testscripts\" sDestinationPath = "C:\Script\files\outzips\" sOutputFilename = shell.ExpandEnvironmentStrings("%COMPUTERNAME%") sFileExt = ".evtx" sFilePrefix = "Archive*" Dim Command, RetVal Dim d : d = Date() Dim dateStr : dateStr = Year(d) & "-" & Right("00" & Month(d), 2) & "-" & Right("00" & Day(d), 2) Dim t : t = Time() Dim timeStr: timeStr = Hour(t) & "-" & Right("00" & Minute(t), 2) & "-" & Right("00" & Second(t), 2) Command = """C:\Program Files\7-zip\7z.exe"" a " & sDestinationPath & sOutputFilename & "-" & dateStr & "-" & timeStr & ".zip " & sDirectoryPath & sFilePrefix & sFileExt RetVal = Shell.Run(Command,0,true) Wscript.Sleep 2000 Dim objFso Set objFSO = CreateObject("Scripting.FileSystemObject") 'Copy files from one path to another o
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft https://msdn.microsoft.com/en-us/library/e1wf9e7w(v=vs.84).aspx Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired http://www.bleepingcomputer.com/forums/t/304603/vbscript-error-help/ content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. FileSystemObject FileSystemObject Reference (Windows error handling Scripting) FileSystemObject Methods FileSystemObject Methods CopyFile Method CopyFile Method CopyFile Method Add Method (Folders) BuildPath Method Close Method (FileSystemObject) Copy Method (FileSystemObject) CopyFile Method CopyFolder Method CreateFolder Method CreateTextFile Method Delete Method DeleteFile Method DeleteFolder Method DriveExists Method FileExists Method FolderExists Method GetAbsolutePathName Method copyfile error handling GetBaseName Method GetDrive Method GetDriveName Method GetExtensionName Method GetFile Method GetFileName Method GetFileVersion Method GetFolder Method GetParentFolderName Method GetSpecialFolder Method GetStandardStream Method GetTempName Method Move Method MoveFile Method MoveFolder Method OpenAsTextStream Method OpenTextFile Method Read Method ReadAll Method ReadLine Method Skip Method SkipLine Method Write Method (FileSystemObject) WriteBlankLines Method WriteLine Method (FileSystemObject) TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. CopyFile Method Copies one or more files from one location to another.Syntax Copy object.CopyFile ( source, destination[, overwrite] ) ArgumentsobjectRequired. The object is always the name of a FileSystemObject.sourceRequired. Character string file specification, which can include wildcard characters, for one or more files to be copied.destinationRequired. Character strin
List Welcome Guide More BleepingComputer.com → Software → Programming Javascript Disabled Detected You currently have javascript disabled. Several functions may not work. Please re-enable javascript to access full functionality. Register a free account to unlock additional features at BleepingComputer.com Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site. Click here to Register a free account now! or read our Welcome Guide to learn how to use this site. VBScript Error help Started by doomgiver13 , Mar 24 2010 11:54 AM Please log in to reply 4 replies to this topic #1 doomgiver13 doomgiver13 Members 103 posts OFFLINE Local time:12:14 AM Posted 24 March 2010 - 11:54 AM The following is a script i'm using to push updated files over my network. I keep getting an error that says "can't find path". Is there any way that when I run this, I can find out which loop iteration it is failing on? I could go to the reference file and just start changing computer names but if I can somehow ID the fail point, it could be useful in troubleshooting other scripting problems I may encounter. Also, is it possible to have the script skip the errored iteration and move on to the next loop? [codebox]Const ForReading = 1 Const OverwriteExisting = TRUE Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\Computers.txt") Do Until objFile