Функция Command
Функцию Command можно использовать для Аргумент части командная строка запуска Microsoft Office Access 2007.
Замечания
При запуске Access из командной строки любая часть командной строки, следующая за параметром / cmd, передается программе в качестве аргумента командной строки. Функцию Command можно использовать для возврата переданного аргумента.
Чтобы изменить аргумент командной строки после открытия базы данных, выполните следующие действия:
В меню Файл выберите пункт Параметры Access.
В диалоговом окне Параметры приложения выберите категорию Дополнительно.
В поле Аргументы командной строки введите новый аргумент.
После этого функция Command будет возвращать введенный аргумент.
Если функция Command используется где-либо, кроме кода Visual Basic для приложений (VBA) в модуле, после нее следует вводить пустые круглые скобки. Например, чтобы использовать функцию Command в текстовом поле формы, для свойства Данные (ControlSource) текстового поля следует задать следующее выражение:
Пример
Примечание: В примерах ниже показано, как использовать эту функцию в модуле Visual Basic для приложений (VBA). Чтобы получить дополнительные сведения о работе с VBA, выберите Справочник разработчика в раскрывающемся списке рядом с полем Поиск и введите одно или несколько слов в поле поиска.
В данном примере показано, как запустить Access с помощью аргумента командной строки и вернуть значение данного аргумента, используя функцию Command.
Чтобы проверить этот пример, в Windows нажмите кнопку Пуск и выберите команду Выполнить. Введите указанный ниже код в поле Открыть одной строкой. (Части командной строки необходимо заключить в кавычки.)
Затем создайте новый модуль в учебной базе данных «Борей» и добавьте следующую процедуру Sub:
При вызове данной процедуры Access открывает форму Orders (Заказы). Чтобы автоматически вызывать эту процедуру при открытии базы данных, можно создать макрос AutoExec.
Макрокоманда «ЗапускКомандыМеню»
Макрокоманда ЗапускКомандыМеню используется для запуска встроенной команды в классической базе данных Access.
Примечание: В Access 2010 макрокоманда ВыполнитьКоманду была переименована в ЗапускКомандыМеню. Аргумент этой макрокоманды не изменился.
Настройка
Макрокоманда ЗапускКомандыМеню имеет следующий аргумент:
Имя команды, которую вы хотите выполнить. В поле Команда перечислены доступные встроенные команды Access в алфавитном порядке. Это обязательный аргумент.
Замечания
С помощью команды «ЗапускКомандыМеню» можно выполнить команду Access из настраиваемой общая строка меню, меню или глобальное контекстное меню.
Макрокоманду ЗапускКомандыМеню можно добавить в макрос с условными выражениями, чтобы выполнять команду при соблюдении определенных условий.
После преобразования базы данных из предыдущей версии Access некоторые команды могут стать недоступны. Команда может была переименована, перемещена в другое меню или удалена из Access. Макрокоманды КомандаМеню для таких команд невозможно преобразовать в макрокоманды ЗапускКомандыМеню. Для таких команд при открытии макроса будет появляться макрокоманда ЗапускКомандыМеню с пустым аргументом Команда. Необходимо изменить макрос и ввести допустимый аргумент для команды или же удалить макрокоманду ЗапускКомандыМеню.
Чтобы запустить макрокоманду ЗапускКомандыМеню в модуле Visual Basic для приложений (VBA), используйте метод RunCommand объекта Application. (Он эквивалентен методу RunCommand объекта DoCmd.)
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.
AccessChk v6.13
By Mark Russinovich
Published: October 15, 2020
Download AccessChk (957 KB)
Run now from Sysinternals Live.
Introduction
As a part of ensuring that they’ve created a secure environment Windows administrators often need to know what kind of accesses specific users or groups have to resources including files, directories, Registry keys, global objects and Windows services. AccessChk quickly answers these questions with an intuitive interface and output.
Installation
AccessChk is a console program. Copy AccessChk onto your executable path. Typing «accesschk» displays its usage syntax.
Using AccessChk
Parameter | Description |
---|---|
-a | Name is a Windows account right. Specify «*» as the name to show all rights assigned to a user. Note that when you specify a specific right, only groups and accounts directly assigned to the right are displayed. |
-c | Name is a Windows Service, e.g. ssdpsrv. Specify «*» as the name to show all services and «scmanager» to check the security of the Service Control Manager. |
-d | Only process directories or top-level keys |
-e | Only show explicitly set-Integrity Levels (Windows Vista and higher only) |
-f | If following -p, shows full process token information including groups and privileges. Otherwise is a list of comma-separated accounts to filter from the output. |
-h | Name is a file or printer share. Specify ‘*’ as the name to show all shares. |
-i | Ignore objects with only inherited ACEs when dumping full access control lists. |
-k | Name is a Registry key, e.g. hklm\software |
-l | Show full security descriptor. Add -i to ignore inherited ACEs. |
-n | Show only objects that have no access |
-o | Name is an object in the Object Manager namespace (default is root). To view the contents of a directory, specify the name with a trailing backslash or add -s. Add -t and an object type (e.g. section) to see only objects of a specific type. |
-p | Name is a process name or PID, e.g. cmd.exe (specify «*» as the name to show all processes). Add -f to show full process token information, including groups and privileges. Add -t to show threads. |
-q | Omit Banner |
-r | Show only objects that have read access |
-s | Recurse |
-t | Object type filter, e.g. «section» |
-u | Suppress errors |
-v | Verbose (includes Windows Vista Integrity Level) |
-w | Show only objects that have write access |
If you specify a user or group name and path, AccessChk will report the effective permissions for that account; otherwise it will show the effective access for accounts referenced in the security descriptor.
By default, the path name is interpreted as a file system path (use the «\pipe\» prefix to specify a named pipe path). For each object, AccessChk prints R if the account has read access, W for write access, and nothing if it has neither. The -v switch has AccessChk dump the specific accesses granted to an account.
Examples
The following command reports the accesses that the Power Users account has to files and directories in \Windows\System32:
accesschk «power users» c:\windows\system32
This command shows which Windows services members of the Users group have write access to:
accesschk users -cw *
To see what Registry keys under HKLM\CurrentUser a specific account has no access to:
accesschk -kns austin\mruss hklm\software
To see the security on the HKLM\Software key:
accesschk -k hklm\software
To see all files under \Users\Mark on Vista that have an explicit integrity level:
accesschk -e -s c:\users\mark
To see all global objects that Everyone can modify:
accesschk -wuo everyone \basednamedobjects
Download AccessChk (957 KB)
Run now from Sysinternals Live.
Command object (ADO) Command object (ADO)
Область применения: Access 2013, Office 2013 Applies to: Access 2013, Office 2013
Определяет определенную команду, которую вы собираетесь выполнить для источника данных. Defines a specific command that you intend to execute against a data source.
Заметки Remarks
Используйте объект Command для запроса базы данных и возврата записей в объекте Recordset, для выполнения массовой операции или для управления структурой базы данных. Use a Command object to query a database and return records in a Recordset object, to execute a bulk operation, or to manipulate the structure of a database. В зависимости от функциональности поставщика при ссылке на некоторые коллекции команд, методы или свойства могут возникнуть ошибки. Depending on the functionality of the provider, some Command collections, methods, or properties may generate an error when referenced.
С помощью коллекций, методов и свойств объекта Command можно сделать следующее: With the collections, methods, and properties of a Command object, you can do the following:
Определите исполняемый текст команды (например, SQL) со свойством CommandText. Define the executable text of the command (for example, an SQL statement) with the CommandText property.
Определите параметризованные запросы или аргументы хранимых процедур с объектами Parameter и коллекцией Parameters. Define parameterized queries or stored-procedure arguments with Parameter objects and the Parameters collection.
Выполните команду и вернете объект Recordset, если это необходимо с помощью метода Execute. Execute a command and return a Recordset object if appropriate with the Execute method.
Укажите тип команды со свойством CommandType перед выполнением для оптимизации производительности. Specify the type of command with the CommandType property prior to execution to optimize performance.
Уберите, сохраняет ли поставщик подготовленную (или скомпилную) версию команды перед выполнением с помощью свойства Prepared. Control whether the provider saves a prepared (or compiled) version of the command prior to execution with the Prepared property.
Установите время в секундах, в течение которое поставщик будет ждать выполнения команды со свойством CommandTimeout. Set the number of seconds that a provider will wait for a command to execute with the CommandTimeout property.
Связывание открытого подключения с объектом Command путем установки его свойства ActiveConnection. Associate an open connection with a Command object by setting its ActiveConnection property.
Установите свойство Name, чтобы определить объект Command как метод для связанного объекта Connection. Set the Name property to identify the Command object as a method on the associated Connection object.
Передав объект Command свойству Source объекта Recordset, чтобы получить данные. Pass a Command object to the Source property of a Recordset in order to obtain data.
Доступ к атрибутам поставщика с помощью коллекции Properties. Access provider-specific attributes with the Properties collection.
Чтобы выполнить запрос без использования объекта Command, передайте строку запроса методу Execute объекта Connection или методу Open объекта Recordset. To execute a query without using a Command object, pass a query string to the Execute method of a Connection object or to the Open method of a Recordset object. Однако объект Command необходим, если необходимо сохранить текст команды и выполнить его повторно, или использовать параметры запроса. However, a Command object is required when you want to persist the command text and re-execute it, or use query parameters.
Чтобы создать объект Command независимо от ранее определенного объекта Connection, задайте для его свойства ActiveConnection допустимую строку подключения. To create a Command object independently of a previously defined Connection object, set its ActiveConnection property to a valid connection string. ADO по-прежнему создает объект Connection, но не назначает этот объект объектной переменной. ADO still creates a Connection object, but it doesn’t assign that object to an object variable. Однако если вы связываете несколько объектов Command с одинаковым подключением, необходимо явно создать и открыть объект Connection; При этом объект Connection назначается объектной переменной. However, if you are associating multiple Command objects with the same connection, you should explicitly create and open a Connection object; this assigns the Connection object to an object variable. Если свойство ActiveConnection объекта Command не установлено для этой переменной объекта, ADO создает новый объект Connection для каждого объекта Command, даже если используется та же строка подключения. If you do not set the Command object’s ActiveConnection property to this object variable, ADO creates a new Connection object for each Command object, even if you use the same connection string.
Чтобы выполнить команду, просто вызовите ее по свойству Name связанного объекта Connection. To execute a Command, simply call it by its Name property on the associated Connection object. Для свойства ActiveConnection команды должен быть установлен объект Connection. The Command must have its ActiveConnection property set to the Connection object. Если команда имеет параметры, передав их значения в качестве аргументов методу. If the Command has parameters, pass their values as arguments to the method.
Если два или более объектов Command выполняются в одном подмосковном соединении и любой из них является хранимой процедурой с выходными параметрами, возникает ошибка. If two or more Command objects are executed on the same connection and either Command object is a stored procedure with output parameters, an error occurs. Чтобы выполнить каждый объект Command, используйте отдельные подключения или отключите все остальные объекты Command от подключения. To execute each Command object, use separate connections or disconnect all other Command objects from the connection.
Коллекция Parameters является членом объекта Command по умолчанию. The Parameters collection is the default member of the Command object. В результате два следующих кода являются эквивалентными. As a result, the following two code statements are equivalent.