- Windows commands
- Prerequisites
- Command shell overview
- Command-line reference A-Z
- Command-line Options
- Parameters
- Session
- Logging
- Console/scripting mode
- Operations
- Configuration
- Mass-modification of sites
- Private key conversion and modification
- Auxiliary
- Syntax
- Executables
- Команды Windows Windows commands
- Предварительные требования Prerequisites
- Общие сведения о командной оболочке Command shell overview
- Справочник по командной строке A-Z Command-line reference A-Z
Windows commands
All supported versions of Windows (server and client) have a set of Win32 console commands built in.
This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.
Prerequisites
The information that is contained in this topic applies to:
- Windows Server 2019
- Windows Server (Semi-Annual Channel)
- Windows Server 2016
- Windows Server 2012 R2
- Windows Server 2012
- Windows Server 2008 R2
- Windows Server 2008
- Windows 10
- Windows 8.1
Command shell overview
The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. With Windows Script Host you could run more sophisticated scripts in the Command shell. For more information, see cscript or wscript. You can perform operations more efficiently by using scripts than you can by using the user interface. Scripts accept all Commands that are available at the command line.
Windows has two command shells: The Command shell and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Cmdlets are similar to Windows Commands but provide a more extensible scripting language. You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.
You can also download and install PowerShell Core, the open source version of PowerShell.
Incorrectly editing the registry may severely damage your system. Before making the following changes to the registry, you should back up any valued data on the computer.
To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:
To set the reg_DWOrd value, use the hexadecimal value of a control character for a particular function (for example, 0 9 is Tab and 0 08 is Backspace). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
Command-line reference A-Z
To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.
Command-line Options
Parameters
Parameters for winscp.exe executable:
Session
The first syntax opens the site. To open site, stored in folder, use path syntax “folder/site”. You can also open workspace or all sites in site folder.
The second creates the session specified by session URL and optionally by initial remote path. If the remote path is not ended by slash ( / ), it is treated as path to file (or even directory) that should be downloaded.
The parameter /sessionname specifies a custom name of the session to be used instead of the automatically generated name in a format username@hostname or to override the name of the saved site.
If there’s already idle WinSCP instance running, the session(s) opens in the existing instance. To force session open in new instance of WinSCP, use /newinstance parameter.
The parameter /privatekey specifies a local path to an SSH private key file. If the key file is encrypted, use the /passphrase to specify its passphrase.
You can use the parameters /username and /password as an alternative way to specify the credentials. The credentials are normally part of the session URL. Using these switches has the advantage of not needing to URL-encode special characters. This feature is available only in the latest beta release.
The parameter /clientcert specifies a local path to FTPS or WebDAVS TLS/SSL client certificate. If the certificate is encrypted, use the /passphrase to specify its passphrase.
When a FTPS or WebDAVS server TLS/SSL certificate is not trusted (typically a self-signed certificate), use the parameter /certificate to specify the fingerprint of the untrusted certificate. It makes WinSCP trust the certificate. Several alternative fingerprints can be separated by a semicolon.
The parameter /passive enables a passive ( =on ) or an active ( =off ) transfer mode (FTP protocol only).
The parameters /implicit , and /explicit enable respective method of invoking FTPS.
The parameter /timeout specifies server response timeout.
The parameter /rawsettings allows configuring any site settings using raw format as in an INI file. E.g. to enable an SSH compression and an agent forwarding, use /rawsettings Compression=1 AgentFwd=1 . The parameter must come after the session URL (if any).
When using scripting, use the open command (and its switches) instead.
Logging
With /log parameter you may turn on session logging to file specified by local path.
Use parameter /loglevel to change logging level. The value can be in range -1 … 2 (for Reduced, Normal, Debug 1 and Debug 2 logging levels respectively). Append additional * to enable password logging (e.g. /loglevel=2* ).1
Use parameter /logsize to configure log file size limit and log file rotation. Specify maximum size in bytes, optionally with K , M or G units. Optionally you can limit number of archived log files using count* prefix. For example /logsize=5*10M will limit log file size to 10 MB and will allow up to 5 archived logs.
With /xmllog parameter you may turn on XML logging to file specified by local path.2 In either path you can use the same patterns as in the logging preferences.
Use parameter /xmlgroups along with /xmllog , to group all XML log elements belonging to the same command under parent group element.
Console/scripting mode
Parameter /console executes WinSCP in console (scripting) mode. Note that when using winscp.com , the console mode is implicit, so using /console parameter is redundant.
To run batch script either pass script file using /script parameter or specify the commands directly on command line using /command . In the latter case each following parameter is treated as single command. See syntax section and examples below for details how to deal with spaces and double-quotes.
If both /script and /command parameters are used, commands from script file are executed first. When the last command is not exit , regular non-batch mode follows.
Use parameter /parameter to specify list of arguments to be passed to script. It is recommended to escape the arguments with // switch.
With winscp.exe , if /console parameter is not used along with /script or /command , the script/command is executed without visual feedback (window).
Use the parameter /stdout to enable streaming files to the standard output. When the parameter is used, the get command will stream the downloaded file(s) to the standard output, when — is used as a download target. By default (or with the binary flag), the files are streamed unmodified. With the chunked flag, the files are individually encoded using Chunked transfer encoding, what allows separating contents of multiple streamed files. When the parameter is used, all console output that would normally be printed to the standard output is redirected to the error output. This feature is available only in the latest beta release.
Use the parameter /stdin to enable streaming files from the standard input. When the parameter is used, the put command will stream the standard input to the remote server, when — is used as an upload source. Implies /nointeractiveinput . This feature is available only in the latest beta release.
Use parameter /nointeractiveinput , when feeding commands to winscp.com using standard input, to make sure prompts for anything other than commands (such as password prompts) are cancelled. Also prevents error message popping up when fatal error occurs while starting WinSCP. When combined with /xmllog the fatal error is recorded in the XML log.
Operations
The following parameters can be used to create a shortcut that initiates operation in GUI mode. They are not intended for automation, for that see scripting.
Use /edit to open a remote file in WinSCP internal editor.
Use /browse to select the specified file in (both) file panel(s). The switch can also be used together with a file URL for the same effect, overriding the default download action.
With /synchronize or /keepuptodate parameter WinSCP performs Synchronize or Keep remote directory up to date commands respectively on the specified session and directories. A dialog to set options is displayed first.
With /upload parameter WinSCP uploads specified files to initial remote directory of session.3 A dialog to set options is displayed first.
Use /defaults parameter along with /upload , /synchronize or /keepuptodate to skip the settings dialog and start the operation straight away with default settings. Alternatively you can specify a number of seconds, to actually show the settings dialogs, but have them automatically submit after the specified time elapses.
Use the /refresh parameter to reload remote panel of all running instances of WinSCP. If a session is specified on command-line, only instances that have that session as active are refreshed. If a path is specified after the /refresh , only that directory is refreshed.
It is recommended to escape the arguments with // switch.
Configuration
With /ini parameter you may specify local path to configuration INI file. It effectively disables using registry as configuration storage. If the file does not exist, default configuration will be used and the file will be created.
Use nul instead of path to force WinSCP start with its default configuration and not save the configuration on exit.
With /rawconfig parameter you can set any configuration settings using raw format as in an INI file. E.g. to configure an external IP address use /rawconfig Interface\ExternalIpAddress=198.51.100.10 . The parameter must come after a session URL (if any). The configuration set this way is preserved.
With /rawtransfersettings you can set any transfer settings using raw format as in an INI file. E.g. to enable preserving of directory timestamps, use /rawtransfersettings PreserveTimeDirs=1 . The configuration set this way is preserved. In scripting, it is better to use -rawtransfersettings switch of individual scripting commands, like get , put , etc.
Mass-modification of sites
Use /batchsettings to mass-modify stored sites. The first argument is a mask to select sites to modify. Use a syntax of basic file masks. You can also use path mask to select sites based on their folders. The other arguments define new values for site settings. Use the same syntax as for /rawsettings .
For example to configure a proxy for all sites in a “clients” folder, use:
Private key conversion and modification
Use the /keygen switch to convert private keys from other formats to a PuTTY .ppk format or to change their passphrase or comment.
A parameter after the /keygen switch specifies a path to an input private key file. The input key can be in OpenSSH or ssh.com format (when converting the key to the PuTTY format) or in the PuTTY format (when changing a key passphrase or comment).
When converting the key from other format, you need to specify an output key path using the /output switch. When modifying a PuTTY key, the existing file is overwritten, if /output is not specified.
Use /changepassphrase switch to change the key passphrase.
Use /comment switch to change the key comment.
For example, to convert key mykey.pem from OpenSSH format to mykey.ppk in PuTTY format and set its comment:
To change the passphrase of existing mykey.ppk :
For a compatibility with *nix puttygen , the -o , -P and -C switches are understood as aliases to /output , /changepassphrase and /comment respectively. So, for features supported by WinSCP, you can use the same arguments as for puttygen , just prefixed with /keygen :
Auxiliary
When run with /update parameter, WinSCP only checks for its updates.
The parameter /info lists the supported SSH and TLS/SSL algorithms.
Parameter /help shows usage (overview similar to this).
Syntax
Command-line parameters that include space(s) must be surrounded by double-quotes:
To use the double-quote as a literal, use two double-quotes sequentially. For example, the /command expects that each script command is surrounded by double quotes, so that it is passed as a single command-line argument. In addition, any script command argument that includes spaces is expected to be surrounded by double-quotes within the command (see doubling double-quotes):
When executing such command from PowerShell, you additionally have to escape the doubled inner double-quotes with ` (backtick) to prevent PowerShell from interpreting them on its own:4
To debug the quoting, enable session logging on level Debug 1 ( /loglevel=1 ). The log will show how WinSCP understands your command-line.
An argument that begins with a slash is considered a switch. To pass a parameter that itself starts with the slash in its syntax (i.e. a remote path like /root ), use the special switch // (two slashes) before the argument. The switch // denotes that all following arguments are not switches. Example:
Executables
Learn about two WinSCP executables, winscp.exe and winscp.com .
If you are going to run WinSCP from command-line often, you may wish to add WinSCP installation directory to search path.
Команды Windows Windows commands
Все поддерживаемые версии Windows (сервер и клиент) имеют набор встроенных команд консоли Win32. All supported versions of Windows (server and client) have a set of Win32 console commands built in.
Этот набор документации описывает команды Windows, которые можно использовать для автоматизации задач с помощью скриптов или средств создания скриптов. This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.
Предварительные требования Prerequisites
Сведения, содержащиеся в этом разделе, применимы к: The information that is contained in this topic applies to:
- Windows Server 2019 Windows Server 2019
- Windows Server (Semi-Annual Channel) Windows Server (Semi-Annual Channel)
- Windows Server 2016 Windows Server 2016
- Windows Server 2012 R2 Windows Server 2012 R2
- Windows Server 2012 Windows Server 2012
- Windows Server 2008 R2 Windows Server 2008 R2
- Windows Server 2008 Windows Server 2008
- Windows 10 Windows 10
- Windows 8.1 Windows 8.1
Общие сведения о командной оболочке Command shell overview
Командная оболочка была первой оболочкой, встроенной в Windows, для автоматизации стандартных задач, таких как управление учетными записями пользователей или ночное резервное копирование с пакетными файлами (bat). The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. С помощью сервера сценариев Windows можно выполнять более сложные сценарии в командной оболочке. With Windows Script Host you could run more sophisticated scripts in the Command shell. Дополнительные сведения см. в разделе cscript или Wscript. For more information, see cscript or wscript. С помощью скриптов можно более эффективно выполнять операции, чем с помощью пользовательского интерфейса. You can perform operations more efficiently by using scripts than you can by using the user interface. Скрипты принимают все команды, доступные в командной строке. Scripts accept all Commands that are available at the command line.
Windows имеет две командные оболочки: Командная оболочка и PowerShell. Windows has two command shells: The Command shell and PowerShell. Каждая оболочка представляет собой программную программу, обеспечивающую прямой обмен данными между вами и операционной системой или приложением, предоставляя среду для автоматизации ИТ-операций. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
PowerShell был разработан для расширения возможностей командной оболочки для выполнения команд PowerShell, называемых командлетами. PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Командлеты похожи на команды Windows, но предоставляют более расширяемый язык сценариев. Cmdlets are similar to Windows Commands but provide a more extensible scripting language. Вы можете выполнять команды Windows и командлеты PowerShell в PowerShell, но Командная оболочка может выполнять только команды Windows, а не командлеты PowerShell. You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
Для наиболее надежной и последней версии службы автоматизации Windows рекомендуется использовать PowerShell вместо команд Windows или сервера сценариев Windows для службы автоматизации Windows. For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.
Вы также можете скачать и установить PowerShell Core, версию PowerShell с открытым исходным кодом. You can also download and install PowerShell Core, the open source version of PowerShell.
Неправильное изменение реестра может серьезно повредить систему. Incorrectly editing the registry may severely damage your system. Перед внесением следующих изменений в реестр следует создать резервную копию всех ценных данных на компьютере. Before making the following changes to the registry, you should back up any valued data on the computer.
Чтобы включить или отключить завершение имен файлов и каталогов в командной оболочке на компьютере или в сеансе входа пользователя, запустите regedit.exe и задайте следующее значение reg_DWOrd: To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\completionChar\reg_DWOrd HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\completionChar\reg_DWOrd
Чтобы задать значение reg_DWOrd , используйте шестнадцатеричное значение управляющего символа для конкретной функции (например, 0 9 — TAB, а 0 08 — Backspace). To set the reg_DWOrd value, use the hexadecimal value of a control character for a particular function (for example, 0 9 is Tab and 0 08 is Backspace). Заданные пользователем параметры имеют приоритет над параметрами компьютера, а параметры командной строки имеют приоритет над параметрами реестра. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
Справочник по командной строке A-Z Command-line reference A-Z
Чтобы найти сведения о конкретной команде, в следующем меню A-Z щелкните букву, с которой начинается команда, а затем щелкните имя команды. To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.
Объект | Б | C | Г | Д | F | Ж | З | Я | J | Л | L | М | N | O | P | Вопросы и ответы | Язык R | С | T | U | Версия | Н | X | Y | Гармошкой A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z