- Windows copy window image
- Syntax
- Parameters
- Remarks
- Examples
- CopyImage function (winuser.h)
- Syntax
- Parameters
- Return value
- Remarks
- Capture and apply Windows, system, and recovery partitions
- Capture the customized partitions
- Step 1: Determine which partitions to capture
- Step 2: Prepare to capture partitions
- Step 3: Capture images for each customized partition.
- Step 4: Save images to the network or another safe location.
- Apply the images
- Step 1: Prepare to apply partitions
- Step 2: Apply the partitions
- Step 3: Verify that it worked
Windows copy window image
Copies one or more files from one location to another.
You can also use the copy command, with different parameters, from the Recovery Console. For more information about the recovery console, see Windows Recovery Environment (Windows RE).
Syntax
Parameters
Parameter | Description |
---|---|
/d | Allows the encrypted files being copied to be saved as decrypted files at the destination. |
/v | Verifies that new files are written correctly. |
/n | Uses a short file name, if available, when copying a file with a name longer than eight characters, or with a file name extension longer than three characters. |
/y | Suppresses prompting to confirm that you want to overwrite an existing destination file. |
/-y | Prompts you to confirm that you want to overwrite an existing destination file. |
/z | Copies networked files in restartable mode. |
/a | Indicates an ASCII text file. |
/b | Indicates a binary file. |
Required. Specifies the location from which you want to copy a file or set of files. Source can consist of a drive letter and colon, a directory name, a file name, or a combination of these. | |
Required. Specifies the location to which you want to copy a file or set of files. Destination can consist of a drive letter and colon, a directory name, a file name, or a combination of these. | |
/? | Displays help at the command prompt. |
Remarks
You can copy an ASCII text file that uses an end-of-file character (CTRL+Z) to indicate the end of the file.
If /a precedes or follows a list of files on the command line, it applies to all files listed until copy encounters /b. In this case, /b applies to the file preceding /b.
The effect of /a depends on its position in the command-line string: — If /a follows source, the copy command treats the file as an ASCII file and copies data that precedes the first end-of-file character (CTRL+Z). — If /a follows destination, the copy command adds an end-of-file character (CTRL+Z) as the last character of the file.
If /b directs the command interpreter to read the number of bytes specified by the file size in the directory. /b is the default value for copy, unless copy combines files.
If /b precedes or follows a list of files on the command line, it applies to all listed files until copy encounters /a. In this case, /a applies to the file preceding /a.
The effect of /b depends on its position in the command–line string: — If /b follows source, the copy command copies the entire file, including any end-of-file character (CTRL+Z). — If /b follows destination, the copy command doesn’t add an end-of-file character (CTRL+Z).
If a write operation cannot be verified, an error message appears. Although recording errors rarely occur with the copy command , you can use /v to verify that critical data has been correctly recorded. The /v command-line option also slows down the copy command, because each sector recorded on the disk must be checked.
If /y is preset in the COPYCMD environment variable, you can override this setting by using /-y at the command line. By default, you are prompted when you replace this setting, unless the copy command is executed in a batch script.
To append files, specify a single file for destination, but multiple files for source (use wildcard characters or file1+file2+file3 format).
If the connection is lost during the copy phase (for example, if the server going offline breaks the connection), you can use copy /z to resume after the connection is re-established. The /z option also displays the percentage of the copy operation that is completed for each file.
You can substitute a device name for one or more occurrences of source or destination.
If destination is a device (for example, Com1 or Lpt1), the /b option copies data to the device in binary mode. In binary mode, copy /b copies all characters (including special characters such as CTRL+C, CTRL+S, CTRL+Z, and ENTER) to the device, as data. However, if you omit /b, the data is copied to the device in ASCII mode. In ASCII mode, special characters might cause files to combine during the copying process.
If you don’t specify a destination file, a copy is created with the same name, modified date, and modified time as the original file. The new copy is stored in the current directory on the current drive. If the source file is on the current drive and in the current directory and you do not specify a different drive or directory for the destination file, the copy command stops and displays the following error message:
If you specify more than one file in source, the copy command combines them all into a single file using the file name specified in destination. The copy command assumes the combined files are ASCII files unless you use the /b option.
To copy files that are 0 bytes long, or to copy all of a directory’s files and subdirectories, use the xcopy command.
To assign the current time and date to a file without modifying the file, use the following syntax:
Where the commas indicate that the destination parameter has been intentionally left out.
Examples
To copy a file called memo.doc to letter.doc in the current drive and ensure that an end-of-file character (CTRL+Z) is at the end of the copied file, type:
To copy a file named robin.typ from the current drive and directory to an existing directory named Birds that is located on drive C, type:
If the Birds directory doesn’t exist, the file robin.typ is copied into a file named Birds that is located in the root directory on the disk in drive C.
To combine Mar89.rpt, Apr89.rpt, and May89.rpt, which are located in the current directory, and place them in a file named Report (also in the current directory), type:
If you combine files, the copy command marks the destination file with the current date and time. If you omit destination, the files are combined and stored under the name of the first file in the list.
To combine all files in Report, when a file named Report already exists, type:
To combine all files in the current directory that have the .txt file name extension into a single file named Combined.doc, type:
To combine several binary files into one file by using wildcard characters, include /b. This prevents Windows from treating CTRL+Z as an end-of-file character. For example, type:
If you combine binary files, the resulting file might be unusable due to internal formatting.
CopyImage function (winuser.h)
Creates a new image (icon, cursor, or bitmap) and copies the attributes of the specified image to the new one. If necessary, the function stretches the bits to fit the desired size of the new image.
Syntax
Parameters
A handle to the image to be copied.
The type of image to be copied. This parameter can be one of the following values.
Value | Meaning |
---|---|
IMAGE_BITMAP 0 | Copies a bitmap. |
IMAGE_CURSOR 2 | Copies a cursor. |
IMAGE_ICON 1 | Copies an icon. |
The desired width, in pixels, of the image. If this is zero, then the returned image will have the same width as the original hImage.
The desired height, in pixels, of the image. If this is zero, then the returned image will have the same height as the original hImage.
This parameter can be one or more of the following values.
Value | Meaning |
---|---|
LR_COPYDELETEORG 0x00000008 | Deletes the original image after creating the copy. |
LR_COPYFROMRESOURCE 0x00004000 | Tries to reload an icon or cursor resource from the original resource file rather than simply copying the current image. This is useful for creating a different-sized copy when the resource file contains multiple sizes of the resource. Without this flag, CopyImage stretches the original image to the new size. If this flag is set, CopyImage uses the size in the resource file closest to the desired size. This will succeed only if hImage was loaded by LoadIcon or LoadCursor, or by LoadImage with the LR_SHARED flag. |
LR_COPYRETURNORG 0x00000004 | Returns the original hImage if it satisfies the criteria for the copy—that is, correct dimensions and color depth—in which case the LR_COPYDELETEORG flag is ignored. If this flag is not specified, a new object is always created. |
LR_CREATEDIBSECTION 0x00002000 | If this is set and a new bitmap is created, the bitmap is created as a DIB section. Otherwise, the bitmap image is created as a device-dependent bitmap. This flag is only valid if uType is IMAGE_BITMAP. |
LR_DEFAULTSIZE 0x00000040 | Uses the width or height specified by the system metric values for cursors or icons, if the cxDesired or cyDesired values are set to zero. If this flag is not specified and cxDesired and cyDesired are set to zero, the function uses the actual resource size. If the resource contains multiple images, the function uses the size of the first image. |
LR_MONOCHROME 0x00000001 | Creates a new monochrome image. |
Return value
If the function succeeds, the return value is the handle to the newly created image.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
When you are finished using the resource, you can release its associated memory by calling one of the functions in the following table.
Resource | Release function |
---|---|
Bitmap | DeleteObject |
Cursor | DestroyCursor |
Icon | DestroyIcon |
В
The system automatically deletes the resource when its process terminates, however, calling the appropriate function saves memory and decreases the size of the process’s working set.
Capture and apply Windows, system, and recovery partitions
When you’re deploying Windows using the WIM format, and using customized partitions, a customized system partition or an additional utility partition, learn how to capture the right partitions to apply to new PCs.
If you don’t need custom partitions, you usually can just capture the Windows partition, and then use files from that image to set up the rest of the partitions on the drive. See Capture and Apply Windows using a single WIM file.
If you’re capturing using the FFU format, you’ll be fine — FFU captures all of the partitions on the drive.
Capture the customized partitions
Step 1: Determine which partitions to capture
This table shows the types of partitions that you must capture and those that are managed automatically.
If you’re deploying both UEFI and BIOS systems, you can reuse your primary and logical partitions across UEFI-based and BIOS-based devices, but not the other partition types.
Partition type | Should you capture this partition? | Can you reuse the same WIM on UEFI and BIOS firmware? |
---|---|---|
System partition (EFI System Partition or BIOS system partition) | Optional. If only a simple set of partition files is required, you don’t have to capture this partition. | No |
Microsoft Reserved partition (MSR) | No | No |
Primary partitions (Windows partitions, data / utility partitions that you’ve added) | Yes | Yes |
Recovery partition | Optional. If you haven’t customized this partition, you don’t have to capture it. | No |
Extended partition | No | No |
Logical partitions (Windows partitions, data / utility partitions that you’ve added) | Yes | Yes |
Step 2: Prepare to capture partitions
If you’ve booted the Windows image, generalize it so that it can be deployed to other devices. For more information, see Sysprep (Generalize) a Windows installation.
Start your reference device by using WindowsВ PE.
At the WindowsВ PE command prompt, type diskpart to open the DiskPart tool.
Check to see if the partitions that you want to capture have drive letters assigned.
If any of the partitions you want to capture don’t already have a drive letter assigned, continue:
List the disks in your PC:
Select the primary hard disk:
View the partitions:
Select a partition that needs a drive letter:
Assign a letter to the partition with the assign letter command. For example,
Type exit to return to the WindowsВ PE command prompt.
For more information, see the DiskPart Help from the command line, or Diskpart Command line syntax.
Step 3: Capture images for each customized partition.
At the WindowsВ PE command prompt, capture each customized partition, for example:
For more information about using the DISM tool to capture an image, see DISM Image Management Command-Line Options.
Step 4: Save images to the network or another safe location.
Connect an external drive, or connect to a safe network location, for example:
If prompted, provide your network credentials.
Copy the partitions to your network share. For example,
Apply the images
Step 1: Prepare to apply partitions
Start your destination device by using WindowsВ PE.
Connect an external drive, or connect to a safe network location, for example:
If prompted, provide your network credentials.
Wipe the hard drive and create new partitions.
To apply to multiple devices, save the Diskpart commands into a script and run them on each new device. For examples, see Configure UEFI/GPT-Based Hard Drive Partitions or Configure BIOS/MBR-Based Hard Drive Partitions. Example:
Where D: is a USB flash drive or other file storage location.
In these DiskPart examples, the partitions are assigned the letters: System=S, Windows=W, and Recovery=R.
Change the Windows drive letter to a letter that’s near the end of the alphabet, such as W, to avoid drive letter conflicts. Do not use X, because this drive letter is reserved for Windows PE. After the device reboots, the Windows partition is assigned the letter C, and the other partitions don’t receive drive letters.
If you reboot, WindowsВ PE reassigns disk letters alphabetically, starting with the letter C, without regard to the configuration in Windows Setup. This configuration can change based on the presence of different drives, such as USB flash drives.
Optional: speed up the image capture by setting the power scheme to High performance:
Step 2: Apply the partitions
Windows and data partitions: Apply the image(s), example:
where W: is the Windows partition.
System partition: You can either:
Configure the system partition by using the BCDBoot tool. This tool copies and configures system partition files by using files from the Windows partition. For example:
Apply a custom image
Where S: is the system partition
Recovery partition:
a. You can either:
Copy the Windows Recovery Environment (RE) tools into the recovery tools partition.
Where R: is the recovery partition
Apply a custom image
b. Register the location of the recovery tools, and hide the recovery partition using Diskpart. You can use our sample script or perform the steps manually:
Diskpart steps for UEFI:
Diskpart steps for BIOS:
Step 3: Verify that it worked
Reboot the device ( exit ). Windows should boot.
If the device doesn’t boot, (for example, if you receive the error message: Bootmgr not found. Press CTRL+ALT+DEL) check the steps for setting up the system partition:
- See BCDBoot command-line options for more info about copying boot files to the system partition.
- Use the DiskPart tool to check to make sure that the system partition is set to Active.
Complete the out of box experience (OOBE) as a new user, and check the recovery partition:
Check that in File Explorer that the Recovery partition is not visible.
View the partitions exist, either by right-clicking Start and selecting Disk Management, or by using diskpart (Open a command prompt as an administrator > diskpart > select disk 0 > list partition > exit ).