1. Replacing Existing Files with the Replace Utility
The Replace utility
replaces a file in a destination folder with a file from a source
folder. You can use it to copy files in a source folder to a destination
without worrying and all of the usual warnings that Windows provides.
The utility can also place unique files from the source folder into a
destination folder. This utility uses the following syntax:
REPLACE [drive1:][path1]filename [drive2:][path2] [/A] [/P] [/R] [/W]
REPLACE [drive1:][path1]filename [drive2:][path2] [/P] [/R] [/S] [/W] [/U]
Notice that the two command lines use distinctly different command line switch sets. For example, you can't use the /A and the /S command line switches together. The following list describes each of the command line arguments.
drive1/drive2
Specifies the drive for the source and destination. The default is the current drive.
path1/path2
Specifies the
absolute or relative path to use for the source and destination. The
source must be different from the destination. The default is the
current directory.
filename
Defines the file
or directory that you want to replace. You can use wildcard characters
with this command. See the "Working with Wildcard Characters" sidebar
for details.
/A
Adds
any new files to the destination directory. Normally, the Replace
utility will only replace files. You cannot use this command line switch
with the /S or /U switches.
/P
Prompts the user for confirmation prior to replacing a file or adding a new file.
/R
Replaces read-only files, as well as unprotected files. By default, the Replace utility only replaces standard read/write files.
/S
Replaces all of the
files in subdirectories of the destination directory. The Replace
utility replaces all occurrences of the file. If a destination directory
and a subdirectory both contain an instance of a file, the Replace
utility replaces both instances of that file. You can't use this command
line switch with the /A switch.
/W
Waits for the user
to insert a floppy disk or other removable media before beginning the
replacement. Generally, you'd use this option as part of a batch file
where the replacement requires more than one disk.
/U
Replaces
files that are older than the source files. When the destination files
are the same age or newer than the source files, the Replace utility
doesn't replace them. This command line switch is a safety feature that
ensures you don't overwrite newer updates with older files.
2. Taking Ownership of Files with the TakeOwn Utility
Server Core provides a new method of taking ownership of a file using the TakeOwn utility. Given the importance that User Account Control (UAC)
places on ownership for security reasons, using this utility could help
you around some of the problems that UAC can create in user access. In
some cases, you might find that you have to take ownership of a file to
manipulate it effectively. The TakeOwn utility uses the following
syntax.
TAKEOWN [/S system [/U [domain\]username [/P [password]]]] /F filename [/A] [/R
[/D prompt]]
The following list describes each of the command line arguments.
/S
systemSpecifies the remote system that you want to check. In most cases, you'll also need to supply the /U and the /P command line switches when using this switch.
/U
[domain\]userSpecifies the
username on the remote system. This name may not match the username on
the local system. You'll need to supply a domain name when working with a
domain controller.
/P
[password]Specifies the
password for the given user. You can provide the command line switch
without specifying the password on the command line in cleartext. The
system prompts you for the password. Using this feature can help you
maintain the security of passwords used on your system.
/F
filenameSpecifies the object
that you want to own. The object can be a file or directory. You can
include a sharename when required. TakeOwn also lets you use wildcard
characters to define the file or directory specification.
/A
Gives the
Administrators group ownership of the object, instead of the current
user (or the user whose credentials you supplied).
/R
Performs a recursive
search for files meeting the file specification. TakeOwn searches the
current directory first, and then all subdirectories.
/D prompt
Provides
a default answer when the current user doesn't have the list folder
permission for a particular directory. The acceptable answers are Y to
take ownership of the directory or N to skip the directory.