wscript
Узел сценариев Windows предоставляет среду, в которой пользователи могут выполнять скрипты на разных языках, которые используют различные объектные модели для выполнения задач.
Синтаксис
wscript [] [/b] [/d] [/e:] [] [/i] [/job:] [] [/s] [/t:] [/x] [/?] []
Параметры
Параметр | Описание |
---|---|
scriptname | Указывает путь и имя файла скрипта. |
/b | Задает пакетный режим, в котором не отображаются оповещения, ошибки сценариев или запросы ввода. Параметр /b является противоположностью /i. |
/d | Запускает отладчик. |
/e | Указывает подсистему, используемую для выполнения скрипта. Этот параметр позволяет выполнять скрипты, использующие пользовательское расширение имени файла. Без параметра /e можно запускать только сценарии, использующие зарегистрированные расширения имен файлов. Например, при попытке выполнить следующую команду: cscript test.admin Появляется следующее сообщение об ошибке: Input Error: There’s script engine for file extension (Ошибка ввода: отсутствует обработчик скриптов для расширения .admin файла ). Одним из преимуществ использования нестандартных расширений имен файлов является то, что он защищает от случайного двойного выбора скрипта и выполнения чего-то, что вы на самом деле не хотите запускать. Использование этого расширения не создает постоянную связь между расширением .admin имени файла и VBScript. При каждом запуске скрипта, использующего .admin расширение имени файла, необходимо использовать параметр /e. |
/h:cscript | Регистрирует cscript.exe в качестве узла скриптов по умолчанию для выполнения скриптов. |
/h:wscript | Регистрирует wscript.exe в качестве узла скриптов по умолчанию для выполнения скриптов. Это поведение используется по умолчанию, если параметр /h опущен. |
/i | Задает интерактивный режим, в котором отображаются оповещения, ошибки сценариев и запросы ввода. Параметр /i является значением по умолчанию и противоположностью /b. |
/job:\ | Выполняет задание, определенное идентификатором, в WSF-файле скрипта . |
/logo | Указывает, что перед выполнением скрипта в консоли отображается баннер узла сценариев Windows. Параметр /logo используется по умолчанию и является противоположностью /nologo. |
/nologo | Указывает, что баннер «Узел сценариев Windows» не отображается перед выполнением скрипта. Параметр /nologo является противоположностью /logo. |
/s | Сохраняет текущие параметры командной строки для текущего пользователя. |
/t:\ | Указывает максимальное время выполнения скрипта (в секундах). Можно указать до 32 767 секунд. По умолчанию нет ограничений по времени. |
/x | Запускает скрипт в отладчике. |
ScriptArguments | Указывает аргументы, передаваемые в скрипт. Перед каждым аргументом скрипта должна быть косая черта (/). |
/? | Отображает справку в командной строке. |
Комментарии
- Для выполнения этой задачи не требуются учетные данные администратора. Рассмотрите возможность выполнения этой задачи в качестве пользователя без учетных данных администратора в качестве рекомендации по обеспечению безопасности.
- Чтобы открыть командную строку, на начальном экране введите cmd и выберите командную строку.
- Каждый параметр является необязательным. Однако аргументы скрипта невозможно указать без указания скрипта. Если скрипт или аргументы скрипта не указаны, wscript.exe откроется диалоговое окно Параметры узла сценариев Windows . Используйте диалоговое окно, чтобы задать глобальные свойства скриптов для всех сценариев, которыеwscript.exe выполняться на локальном компьютере.
- Параметр /t предотвращает чрезмерное выполнение скриптов, устанавливая таймер. Когда время превышает указанное значение, wscript прерывает работу обработчика скриптов и завершает процесс.
- Файлы сценариев Windows обычно имеют одно из следующих расширений имен файлов: .wsf, .vbs, .js.
- Если дважды выбрать файл скрипта с расширением, которое не имеет связи, появится диалоговое окно Открыть с помощью. Выберите wscript или cscript, а затем выберите Всегда использовать эту программу, чтобы открыть файл этого типа. При этом wscript.exe или cscript.exe в качестве узла скриптов по умолчанию для файлов этого типа.
- Вы можете задать свойства для отдельных скриптов. Дополнительные сведения о узле сценариев Windows см. в статье Общие сведения о узле сценариев Windows.
- Узел сценариев Windows может использовать WSF-файлы скриптов . Каждый WSF-файл может использовать несколько обработчиков сценариев и выполнять несколько заданий.
Связанные ссылки
wscript
Windows Script Host provides an environment in which users can execute scripts in various languages that use various object models to perform tasks.
Syntax
wscript [] [/b] [/d] [/e:] [] [/i] [/job:] [] [/s] [/t:] [/x] [/?] []
Parameters
Parameter | Description |
---|---|
scriptname | Specifies the path and file name of the script file. |
/b | Specifies batch mode, which doesn’t display alerts, scripting errors, or input prompts. The /b parameter is the opposite of /i. |
/d | Starts the debugger. |
/e | Specifies the engine that is used to run the script. This parameter lets you run scripts that use a custom file name extension. Without the /e parameter, you can only run scripts that use registered file name extensions. For example, if you try to run this command: cscript test.admin You receive this error message: Input Error: There’s no script engine for file extension .admin . One advantage of using nonstandard file name extensions is that it guards against accidentally double-selecting a script and running something you didn’t actually want to run. Using this extension doesn’t create a permanent association between the .admin file name extension and VBScript. Each time you run a script that uses a .admin file name extension, you need to use the /e parameter. |
/h:cscript | Registers cscript.exe as the default script host for running scripts. |
/h:wscript | Registers wscript.exe as the default script host for running scripts. This behavior is the default when the /h option is omitted. |
/i | Specifies interactive mode, which displays alerts, scripting errors, and input prompts. The /i parameter is the default and the opposite of /b. |
/job:\ | Runs the job identified by identifier in a .wsf script file. |
/logo | Specifies that the Windows Script Host banner is displayed in the console before the script runs. The /logo parameter is the default and the opposite of /nologo. |
/nologo | Specifies that the Windows Script Host banner isn’t displayed before the script runs. The /nologo parameter is the opposite of /logo. |
/s | Saves the current command prompt options for the current user. |
/t:\ | Specifies the maximum time the script can run (in seconds). You can specify up to 32,767 seconds. The default is no time limit. |
/x | Starts the script in the debugger. |
ScriptArguments | Specifies the arguments passed to the script. Each script argument must be preceded with a slash (/). |
/? | Displays Help at the command prompt. |
Remarks
- Performing this task doesn’t require you to have administrative credentials. Consider performing this task as a user without administrative credentials as a security best practice.
- To open a command prompt, on the Start screen, type cmd, and then select command prompt.
- Each parameter is optional. However you can’t specify script arguments without specifying a script. If you don’t specify a script or any script arguments, wscript.exe displays the Windows Script Host Settings dialog box. Use the dialog box to set global scripting properties for all scripts that wscript.exe runs on the local computer.
- The /t parameter prevents excessive running of scripts by setting a timer. When the time exceeds the specified value, wscript interrupts the script engine and ends the process.
- Windows script files usually have one of the following file name extensions: .wsf, .vbs, .js.
- If you double-select a script file with an extension that has no association, the Open With dialog box appears. Select wscript or cscript, and then select Always use this program to open this file type. This registers wscript.exe or cscript.exe as the default script host for files of this file type.
- You can set properties for individual scripts. For more information about Windows Script Host, see Windows Script Host overview.
- Windows Script Host can use .wsf script files. Each .wsf file can use multiple scripting engines and perform multiple jobs.
Related links
Feedback
Submit and view feedback for
Wscript
Windows Script Host provides an environment in which users can execute scripts in a variety of languages, languages that use a variety of object models to perform tasks.
Syntax
wscript[] [/b] [/d] [/e:] [] [/i] [/job:] [] [/s] [/t:] [/x] [/?] []
Parameters
Specifies the path and file name of the script file.
Specifies batch mode, which does not display alerts, scripting errors, or input prompts.
Starts the debugger.
Specifies the engine that is used to run the script.
Registers cscript.exe as the default script host for running scripts.
Default. Registers wscript.exe as the default script host for running scripts. This is the default.
Specifies interactive mode, which displays alerts, scripting errors, and input prompts.
This is the default and the opposite of /b.
Runs the job identified by identifier in a .wsf script file.
Specifies that the Windows Script Host banner is displayed in the console before the script runs.
This is the default and the opposite of /nologo.
Specifies that the Windows Script Host banner is not displayed before the script runs.
Saves the current command-prompt options for the current user.
Specifies the maximum time the script can run (in seconds). You can specify up to 32,767 seconds.
The default is no time limit.
Starts the script in the debugger.
Specifies the arguments passed to the script. Each script argument must be preceded by a slash (/).
Displays Help at the command prompt.
Remarks
- Performing this task does not require you to have administrative credentials. Therefore, as a security best practice, consider performing this task as a user without administrative credentials.
- To open a command prompt, on the Start screen, type cmd, and then click command prompt.
- Each parameter is optional; however, you cannot specify script arguments without specifying a script. If you do not specify a script or any script arguments, wscript.exe displays the Windows Script Host Settings dialog box, which you can use to set global scripting properties for all scripts that wscript.exe runs on the local computer.
- The /t parameter prevents excessive running of scripts by setting a timer. When the time exceeds the specified value, wscript interrupts the script engine and ends the process.
- Windows script files usually have one of the following file name extensions: .wsf, .vbs, .js.
- If you double-click a script file with an extension that has no association, the Open With dialog box appears. Select wscript or cscript, and then select Always use this program to open this file type. This registers wscript.exe or cscript as the default script host for files of this file type.
- You can set properties for individual scripts. See Windows Script Host overview for more information.
- Windows Script Host can use .wsf script files. Each .wsf file can use multiple scripting engines and perform multiple jobs.
Additional references
При подготовке материала использовались источники:
https://learn.microsoft.com/ru-ru/windows-server/administration/windows-commands/wscript
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wscript
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh875526(v=ws.11)