- Функция Command
- Замечания
- Пример
- Access Linux filesystems in Windows and WSL 2
- Getting started
- Accessing these files with File Explorer
- Limitations
- Give us your feedback!
- Windows commands
- Prerequisites
- Command shell overview
- Command-line reference A-Z
- Problems on calling Microsoft Access with command line from Windows batch file
- Использование параметров командной строки в Microsoft Access
- Дополнительная информация
- Примечания
Функция 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 Linux filesystems in Windows and WSL 2
September 10th, 2020
Starting with Windows Insiders preview build 20211, WSL 2 will be offering a new feature: wsl —mount . This new parameter allows a physical disk to be attached and mounted inside WSL 2, which enables you to access filesystems that aren’t natively supported by Windows (such as ext4).
So, if you’re dual booting with Windows & Linux using different disks, you can now access your Linux files from Windows!
Getting started
To mount a disk, open a PowerShell window with administrator privileges and run:
To list the available disks in Windows, run:
To unmount and detach the disk from WSL 2, run
The disks paths are available under the ‘DeviceID’ columns. Usually under the \\.\\\.\PHYSICALDRIVE* format. Below is an example of mounting a specific partition of a given hard disk into WSL and browsing its files.
Accessing these files with File Explorer
Once mounted, it’s also possible to access these disks through the Windows explorer by navigating to \wsl$ and then to the mount folder.
Limitations
By default, wsl —mount attempts to mount the disk as ext4. To specify a filesystem, or for more advanced scenarios, check out Mount a disk in WSL 2.
Also please note that this feature comes with the limitation that only physical disks can be attached to WSL 2. At this time, it’s not possible to attach a single partition. More details on the limitations here.
Give us your feedback!
If you run into any issues, or have feedback for our team please file an issue on our Github , and if you have general questions about WSL you can find all of our team members that are on Twitter on this twitter list.
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.
Problems on calling Microsoft Access with command line from Windows batch file
I’m trying to write a Windows batch file to call a Microsoft Access application and pass a command to the Access program. That’s fairly easy using Access‘s /cmd switch and the VBA Command() function – as long as the parameters don’t contain special characters, like double quotes or spaces. I also have a requirement that if the batch file isn’t called with any parameters, it will prompt the user for parameters for the command.
For example, here’s a call to test_cmd with parameters:
If the user runs test_cmd without any parameters, the user should be able to do this:
So that leads to three problems:
With the full command line version, the double quotes are removed and not passed to Access. This means that I can’t easily tell where one parameter ends and the next one starts. I solved this by inserting my own delimiters («<#" in the batch file below) in front of %2-%9. That actually works if my VBA code uses the Split function to split on the delimiter, but it's kind of ugly.
With the prompted version, double quotes cause errors saying the next token after the first double quote was not expected. Searching the world wide web led me to command SETLOCAL EnableDelayedExpansion , but then the double quotes are removed when the Command() function gets the command line.
Even after getting #1 working with the delimiter and using single quotes in the prompted version in #2, the command line Access processes often gets truncated.
I realize that this is a bit hard to follow, so I’m including the batch file and a simple Access function (called by an AutoExec macro) that illustrates the problem.
NOTE: The Access module tries both the Command() Access function and the Win32 GetCommandLine function, and both often get truncated at the same place as mentioned in #3 above.
TEST_CMD.BAT
CommandLineTest VBA Module
Is there a simple way to handle this with longer command lines?
Использование параметров командной строки в Microsoft Access
Когда вы запускаете Microsoft Access из меню Пуск или контекстного, вы можете использовать параметры командной строки для модификации процесса загрузки программы. Например, вы можете открыть ту или иную базу данных, запустить макрос или ввести пароль.
Дополнительная информация
Примечания
• | Чтобы при открытии базы данных запустить процедуру Visual Basic for Applications, воспользуйтесь действием RunCode в макросе AutoExec или в макросе, который вы запустили с помощью параметра командной строки /x . При открытии базы данных можно также запустить процедуру Visual Basic, создав форму с процедурой, определенной для ее события формы Visual Basic. Присвойте этой форме значение автозагрузочной. Для этого щелкните правой кнопкой мыши окно Database, выберите Startup и затем войдите в эту форму в поле Display Form/Page . |
• | Чтобы задать в командной строке наклонную черту (/) или точку с запятой (;), введите этот символ дважды. Например, чтобы задать в командной строке пароль ;mjs/md, введите ;;mjs//mdпосле параметра командной строки /pwd . |
• | Примеры: Можно ввести следующую команду в диалоговом окне Пуск , чтобы открыть базу данных Access 2000 в эксклюзивном режиме, при котором во время загрузки запускается указанный макрос: Для получения дополнительных сведений о параметрах командной строки выберите команду Справка: Microsoft Access в меню Справка , затем введите в поле помощника Office или мастера ответов строку параметры запуска из командной строки и нажмите кнопку Поиск . |