System command

replace command

Replace existing files in a directory. This guide lists the documented syntax and parameters for replace; check Microsoft Learn for version, role and execution-context requirements.

Availability: Microsoft Learn command reference spanning Windows client and Windows Server releases; some entries are legacy, role-specific, optional-feature or interactive subcommands.中文

Documented syntax

replace [<drive1>:][<path1>]<filename> [<drive2>:][<path2>] [/a] [/p] [/r] [/w]
replace [<drive1>:][<path1>]<filename> [<drive2>:][<path2>] [/p] [/r] [/s] [/w] [/u]

The linked Microsoft Learn article is the upstream authority. Availability may depend on Windows release, role, optional feature or interactive tool context.

Syntax pattern

Syntax pattern from Microsoft Learn; replace placeholders and choose only one documented alternative before use.

replace [<drive1>:][<path1>]<filename> [<drive2>:][<path2>] [/a] [/p] [/r] [/w]

Parameters, options and clauses

Option / clauseDescription
[<drive1>:][<path1>]<filename>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
[<drive2>:][<path2>]Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<drive1>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<path1>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<filename>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<drive2>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<path2>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
/aMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/pMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/rMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/wMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/sMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/uMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory