What does APPCOMMAND_LAUNCH_APP1 do? - windows

See https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-appcommand for reference.
I've just made a tool to send certain button presses to Windows and I came across this 'button'. It looks like something I could use, but I can't find anything about how it works. I've already tried sending it with my tool, but nothing happens. (I am able to successfully send commands like microphone mute and media play/pause, so my implementation is correct.)
What does APPCOMMAND_LAUNCH_APP1 do? What is app1 or how can I configure what app1 should be?

As Jimi said in the comments, the app1 and app2 applications are defined in the registry. By default it should be Windows Explorer for app1 and Calculator for app2, but it can be modified.
The registry key where these applications can be viewed / redefined is here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey
The numbered keys in AppKey correspond to the command number of the WM_APPCOMMAND sent.
The value may be something like calc.exe if the application can be found in the PATH environment variable, but it may be the path to an executable as well. Even some special commands are supported that Windows will recognize as special folders. See https://www.autohotkey.com/docs/misc/CLSID-List.htm for special folder GUIDs.

Related

Alternative to Windows Alternate Data Streams

I have the following need to implement on Windows: file with files.
Originally I was thinking to use directory with extension. Something like "folderA.myappext", so when user clicks on it in Explorer, my app is launched instead of folder being opened. Unfortunately, I was unable to find a way to do that. Then I tried to use Alternate Data Streams. This works just fine, but several problems with it:
It works only in NTFS, so no way to send it via email or FTP as is;
Only WinRAR can properly archive it, and you still have to do extra clicks in the UI for that;
The real file size (with all streams in it) is not shown in Explorer and does not participate in showing free/used space, which can very quickly lead to big problems for the user.
No, I can't use zip or any other way to combine files into one - this is high-performance app that also requires write streaming (i.e. it changes data all the time).
Any idea how else to achieve my need on Windows? I know on MacOS you can use 'package', but there is nothing like that on Windows. Any idea?
Something like "folderA.myappext", so when user clicks on it in Explorer, my app is launched instead of folder being opened.
You can't do it based on the extension because folders don't have extensions but you can do it with desktop.ini. Windows 7 and later supports custom verbs on folders.
A working example can be found here.

Show publisher name in list of installed programs

I use Wix Toolset v3.11 to generate an .msi installer for my Windows application.
How can I have a publisher name appear in the entry for my application in Settings -> Apps & features?
I noticed that some entries in that list include a publisher name underneath the app name:
I set <Product ... Manufacturer="My Company Name" ... in my .wxs file and I can see this is stored in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\<guid>\Publisher.
But apparently that isn't enough to make the publisher appear in the list of programs. The apps that do show a publisher (Windows Store apps?) are stored in a different part of the registry.
From what I've noticed the publisher's name appears only for apps packages as an .APPX/.MSIX package. Not for those installed from an MSI/EXE setup.
The source of the APPX/MSIX package does not matter, I have packages installed from outside the store (sideloaded) which display the publisher's name correctly.
If you want to learn more about MSIX/APPX packages, check out this introduction guide I wrote.
I, too, wanted to list my name as the publisher of my applications in the Settings Apps & Features list. So, I went searching for how to do that and found your post on Stack Overflow. Then an idea struck so I tried it out, and what-da-ya-know … it worked! Not perfectly, but “good enough” for what I wanted to do. Perhaps good enough for you, and others, also.
In the “Uninstall” Registry key for my apps, I append a line-break character and my name to the “DisplayName” value. Like this:
Registry Entry
The line-break character can be a Line Feed (0A), Vertical Tab (0B), Form Feed (0C), or Carriage Return (0D). Any of them work (as does a CR+LF combination). I like the FF because it displays as an up arrow in RegEdit and text files (such as .reg scripts), which makes it easy to select, cut, copy, and paste.
This method does cause a blank link to appear in the Settings Apps & Features list:
Apps List
But I can live with that, and I suspect that the few users who actually notice the extra blank line won’t give it a second thought. Given how easy it is to add my “Publisher” name, it is an acceptable imperfection.

Adding environment variable to a commandline argument in a windows shortcut

So I'm trying to make a mailto link on a windows desktop. This is to automate opening a mail client by inserting the recipient and subject automatically. I can do just that, however I'd like to include either the current date or the previous date in the beginning of the subject line. I've tried:
%windir%\explorer.exe mailto://user#email.com?subject=%date% 'Rest Of Subject'
and every other variant I can think of. The link either reads %windir% correctly or just skips it but opens fine. However, I see the literal '%date' in my subject.
Is this possible without using batch files or scripting? This is for work different computers at different locations, where users aren't exactly computer savvy and need things done for them. Also for bonus points, is there a way the also make the file attach dialog pop up? The purpose of this is to send security log word document from different locations to a central email address. Thanks and I hope to hear from anyone who can direct me where to look or give me some hints on my command line fu!

Passing arguments while launching program from browser

I am trying to launch an application (.exe) from my browser.
The specific app needs 4 arguments/parameters when launching, which are: firstname, lastname, id, info
Is there a way to add these arguments on the Internet Explorer address bar when i launch my program?
I mean something like this:
"myapp:// -firstname -lastname -id -info"
(I only managed to add those arguments straight to the windows registry, it worked that way. But thats no help... i need them to be inputted when launching the app )
I have added this to my windows registry:
[HKEY_CLASSES_ROOT\myapp]
#="URL:myprogram Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\myapp\DefaultIcon]
#="\"C:\\myapp.exe\""
[HKEY_CLASSES_ROOT\myapp\shell]
[HKEY_CLASSES_ROOT\myapp\shell\open]
[HKEY_CLASSES_ROOT\vsa\shell\open\command]
#="\"C:\\myapp\" "%1"
Thanks for help already! I hope someone knows how to fix this... :)
ps. Im using windows 7 64 bit and Internet Explorer 10.
You cannot simply pass multiple command line arguments to your application (unless they're listed explicitly in the registry as you've shown).
Instead, you must code your application's executable so that it is able to process the Application Protocol URL string. So your code is invoked by the browser like so:
C:\apps\myapp.exe "myapp:myParam?myParam2&myParam3&myParam4"
The executable must be able to process this string and handle it appropriately. You must take care to avoid security holes in the parsing of this string, as ANY webpage could exploit a hole here to escape the browser sandbox and attack the user's system.
There's more information on Application Protocols in this post: http://blogs.msdn.com/b/ieinternals/archive/2011/07/14/url-protocols-application-protocols-and-asynchronous-pluggable-protocols-oh-my.aspx

How does the OS know what to do with a file when the "Open With..." option is selected?

Explanation:
I don't remember about Linux and I don't know about OS X, but in Windows you can right-click a file and select a program to open it. But how does the OS know exactly how to make the program open it? Does it keep track of the "Open file" dialogs the program has? Does the developer have to specify a special event handler or something for these cases?
For Windows, the answer is in the registry. If you're comfortable reading the registry, run regedit.exe on your Windows machine.
Under HKEY_CLASSES_ROOT, you will see a key list of all file types, .doc, .txt, etc. Each of these keys contains a key called "OpenWithList" or "OpenWithProgIds". An application may have a registered "ProgId", also found under HKEY_CLASSES_ROOT, and it can register it's ProgId to the file types it wants to handle in OpenWithProgIds. Otherwise it registers itself in OpenWithList.
In response to the comment to the first answer (cos I don't have enough rep to comment):
You're thinking of DDE, which is a near-enough deprecated technology. The Windows shell executes the application with the selected file as the first parameter.
The Windows Explorer remembers your previous "Open With..." choices based on file extension in the following key:
HKCR\.ext\OpenWithList
Next time you right-click the file, it looks there and build a list of programs you have previously used to open a particular file type.
Say it finds a key named "myapp.exe". It then looks up the application here:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\myapp.exe
fetches the info where the application is installed. And it goes here:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\myapp.exe
follows the GUID stored there to find out the display name of the application.
To add to the fun, the primary associated application is in the list as well, also everything in the OpenWithProgIds key and everything in:
HKEY_CLASSES_ROOT\*\OpenWithList
as well as their respective HKEY_CURRENT_USER counterparts.
The resulting list of applications is then made unique, sorted and displayed. On selection the file is started like any other file you click on - i.e.:
C:\path\to\myapp.exe "C:\path\to\the\file.ext"
http://windowsxp.mvps.org/OpenWith.htm
File associations are stored in the Registry in: HKEY_CLASSES_ROOT.
You can manage them graphically by using Windows Explorer: (WinXP)
Click Tools/Options/File Types
Or with the "Default Programs" applet in Control Panel. (Vista)
Just for some nostalgia the rather brilliant Acorn archimedes had a much better system with each file type having a unique type number, with a manufacturer and application code (rather like a MAC address) which was written with the file.
This means you can have different files all called .bak opened by the correct application - unlike the windows case where a new installed app steals the ownership of every exiting file of that type. Autocad is especialy bad for this, registering about 20 file types.
The operating system runs the specified program sending as parameter the path of the file to open.
For example, in C#, if you want to know which file the operating system wants you to open you'll need to do:
class Program
{
static void Main(string[] args)
{
if (args.Length == 1) //The OS wants me to open a file
openSomeFileJustBecauseTheOSWantsIt(args[0]);
}
}

Resources