Copy Error 1
Contents |
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
Xcopy Return Code 4
Stack Overflow the company Business Learn more about hiring developers or posting ads batch file on error with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow
Robocopy Errorlevel
is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Windows copy command return codes? up vote 18 down vote favorite 3 I xcopy code 2 would like to test for the success/failure of a copy in a batch file, but I can't find any documentation on what if any errorlevel codes are returned. For example copy x y if %errorlevel%. eq 1. ( echo Copy x y failed due to ... exit /B ) else ( if %errorlevel% eq 2. ( echo Copy x y failed due to ... exit /B ) ... etc ... xcopy invalid number of parameters ) windows batch-file share|improve this question asked Nov 21 '11 at 21:55 Bill Ruppert 5,33671540 add a comment| 4 Answers 4 active oldest votes up vote 25 down vote accepted I'd opt for xcopy in this case since the error levels are documented (see xcopy documentation, paraphrased below): Exit code Description ==== =========== 0 Files were copied without error. 1 No files were found to copy. 2 The user pressed CTRL+C to terminate xcopy. 4 Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line. 5 Disk write error occurred. In any case, xcopy is a far more powerful solution. The equivalent documentation for copy does not document the error levels. As an aside, you may want to rethink your use of the %errorlevel% variable. That has nasty ramifications (at least in some versions of Windows) if someone has explicitly done something silly like: set errorlevel=22 In those cases, the actual variable will be used rather than grebbing the actual error level. The "normal" way of doing this is (in decreasing order since errorlevel is a "greater than or equal to" check): if errorlevel 2 ( echo Copy x y failed due
Microsoft Tech Companion App Microsoft Technical Communities Microsoft Virtual Academy Script Center Server and Tools Blogs TechNet Blogs TechNet Flash Newsletter TechNet
Xcopy File Or Directory
Gallery TechNet Library TechNet Magazine TechNet Subscriptions TechNet Video TechNet Wiki xcopy arguments Windows Sysinternals Virtual Labs Solutions Networking Cloud and Datacenter Security Virtualization Downloads Updates Service Packs Security Bulletins
Xcopy Examples
Windows Update Trials Windows Server 2012 R2 System Center 2012 R2 Microsoft SQL Server 2014 SP1 Windows 8.1 Enterprise See all trials » Related Sites Microsoft Download Center http://stackoverflow.com/questions/8219040/windows-copy-command-return-codes TechNet Evaluation Center Drivers Windows Sysinternals TechNet Gallery Training Training Expert-led, virtual classes Training Catalog Class Locator Microsoft Virtual Academy Free Windows Server 2012 courses Free Windows 8 courses SQL Server training Microsoft Official Courses On-Demand Certifications Certification overview MCSA: Windows 10 Windows Server Certification (MCSE) Private Cloud Certification (MCSE) SQL Server Certification (MCSE) Other resources https://technet.microsoft.com/en-us/library/bb491035.aspx TechNet Events Second shot for certification Born To Learn blog Find technical communities in your area Support Support options For business For developers For IT professionals For technical support Support offerings More support Microsoft Premier Online TechNet Forums MSDN Forums Security Bulletins & Advisories Not an IT pro? Microsoft Customer Support Microsoft Community Forums United States (English) Sign in Home Library Wiki Learn Gallery Downloads Support Forums Blogs We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. TechNet Archive Windows XP Command-line reference A-Z Command-line reference A-Z Xcopy Xcopy Xcopy Arp Assoc At Atmadm Attrib Using batch files Bootcfg Break Cacls Call Chcp Chdir (Cd) Chkdsk Chkntfs Cipher Cls Cmd Cmstp Color Comp Compact Convert Copy Using the command-based script host (CScript.exe) Date Diskcomp Diskcopy DiskPart Doskey MS-DOS subsystem commands Driverquery Echo Endlocal Eventcreate Eventquery.vbs Eventtriggers Exit Expand Fc Using filters Find Findstr Finger For Ftp Ftp subcommands Ftype Getmac Goto Gpresult Graftabl Help Helpctr Hostname If Ipconfig I
0×01 1 One or more files were copied successfully (that is, new files have arrived). 0×02 2 Some Extra files or directories were detected. No files were copied Examine the output log for details. 0×04 4 Some Mismatched http://ss64.com/nt/robocopy-exit.html files or directories were detected. Examine the output log. Housekeeping might be required. 0×08 8 Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further. 0×10 16 Serious error. Robocopy did not copy any files. Either a usage error or an error due to insufficient access privileges on the source or destination directories. These can be combined, giving a few extra exit codes: 0×03 3 (2+1) Some files were copied. copy error Additional files were present. No failure was encountered. 0×05 5 (4+1) Some files were copied. Some files were mismatched. No failure was encountered. 0×06 6 (4+2) Additional files and mismatched files exist. No files were copied and no failures were encountered. This means that the files already exist in the destination directory 0×07 7 (4+1+2) Files were copied, a file mismatch was present, and additional files were present. Any value greater than 7 indicates that there was at least one copy error 1 failure during the copy operation. You can use this in a batch file to report anomalies, as follows: if %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto end if %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto end if %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto end if %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto end if %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto end if %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto end if %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto end if %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto end if %ERRORLEVEL% EQU 8 echo FAIL & goto end if %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto end if %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto end if %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto end if %ERRORLEVEL% EQU 4 echo MISMATCHES & goto end if %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA & goto end if %ERRORLEVEL% EQU 2 echo XTRA & goto end if %ERRORLEVEL% EQU 1 echo OKCOPY & goto end if %ERRORLEVEL% EQU 0 echo No Change & goto end :end Example: Copy files from one server to another ROBOCOPY \\Server1\reports \\Server2\backup *.*IF %ERRORLEVEL% LSS 8 goto finish Echo Something failed & goto :eof :finishEcho All done, no fatal errors. Bugs Version XP026 retur