TransWikia.com

Identify the command run after a UI click

Super User Asked by drubs on December 21, 2021

I’m looking for something similar as in here: How to know the corresponding command line cmd for the UI click?

But in my case, under Windows 10 OS.
More specifically, the command run after a UI click in "Open with Code", like in the following image:
Open with VS Code from right click in Windows Explorer

I suppose it’s a simple code . command. But how can I double check that?

I believe this can be done with the help of Event Viewer, but I don’t really know how. I’ve tried the tasklist command, but I didn’t get anything satisfactory as it only outputs processes and not commands.

2 Answers

I might not understand your question but Process Explorer will show you the command line parameters passed to every running process; and it also has a little tool to let you look up the process by clicking on a window that belongs to it. So it should be easy to find out the command that was executed; just perform whatever action runs the thing you're interested in then drag the search thingy over the application's window (or just find it in the list).

For example here is an instance of Notepad I launched by right-clicking on a file in Explorer:

enter image description here

Another option is to use Process Monitor and add an event filter "if Operation is not Process Start then Exclude".

That will cause Process Monitor to just display a running list of process startups. Then you can perform your action, see what appears in the list, and double-click it to show the command line.

Answered by Jason C on December 21, 2021

This menu is called a context menu. The settings of context menu is usually in the registry.

Understanding context menus

First you have to know about the key HKEY_CLASSES_ROOT registry key. It contains all the file extensions and associations, CLSID, ProgID, & IID. Suppose you go the *.txt key. It is the key for text files. The default value of *.txt key is TXTFile, which means the settings, context menus and associations are contained in txtfile key. (Note beside extensions * is the key for all files, Directory for all folders and DesktopBackground for desktop context menu) Go there and you find a key named shell. This is the settings for context menus for text files.

There you will find some other subkeys. They will have the names as the context menu option. Then when you expand them, you will see another key named command. Its default value is the application and its command line arguments when called, if you find %1 it expands to the file fullpath.

If a command needs elevated priviliges then the syntax is bit different. In the shell key, create another key named runas. Then set the default value to the display name in context menu. Then create another subkey named command, and set default value as the path to the application and arguments.

And another thing is the icon. To add an icon, go to the shellThe display namecommand or shellrunascommand key and create a value named icon. Then specify path for the icon.

One thing you may have noticed that there is a underscore like thing in some words of context menu button. If you press Alt + that key then that option is triggered. That is called the accelerator key. That can be also defined. In the default value of runas key or name of subkey in shell key, you can add an ampersnad & just before the letter like "Op&en with" here "e" will be the accelerator key.

If you create a value named "Noworkingdirectory" in command key, then the command will have no current working directory. By default that is the parent folder of file.

Where is VSCode context menus

VSCode context menus are like the same hunt in HKCR*shell or HKCRDesktopBackgroundshell. The command value is Full path of code.exe "%1"

Notes

Not only %1 is special argument, there are many:

%* - replace with all parameters

%~ - replace with all parmaters starting with and following the second parameter

%0 or %1 the first file parameter. For example “C:UsersEricDestopNew Text Document.txt”. Generally this should be in quotes and the applications command line parsing should accept quotes to disambiguate files with spaces in the name and different command line parameters (this is a security best practice and I believe mentioned in MSDN).

% (where N is 2 - 9), replace with the nth parameter

%s – show command

%h – hotkey value

%i – IDList stored in a shared memory handle is passed here.

%l – long file name form of the first parameter. Note win32 applications will be passed the long file name, win16 applications get the short file name. Specifying %L is preferred as it avoids the need to probe for the application type.

%d – desktop absolute parsing name of the first parameter (for items that don’t have file system paths)

%v – for verbs that are none implies all, if there is no parameter passed this is the working directory

%w – the working directory

From https://web.archive.org/web/20111002101214/http://msdn.microsoft.com/en-us/library/windows/desktop/cc144101(v=vs.85).aspx

Helpful Links

Answered by programmer365 on December 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP