Windows registry - register an application to open a file type - windows

I'm making an installer for an application which has a custom URI scheme and its own file type to open with it. The application executed with a launcher.bat, In the registry I've set the launcher.bat to do so. It works as it should be, unless I want to register the application wit its name to be shown as opening application both in exporer and browsers instead of launcher.bat.
The registry file that applied by the installer script is the following (it is gets generated dynamically, so don't mind the application path as well):
Windows Registry Editor Version 5.00
; ---- Add myext extension
[-HKEY_CLASSES_ROOT\.myext]
[HKEY_CLASSES_ROOT\.myext]
"content-type"="application/myext+xml"
#="myapp"
; ---- Add myapp for protocol
[-HKEY_CLASSES_ROOT\myapp]
[HKEY_CLASSES_ROOT\myapp]
#="URL:<Application Protocol>"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\myapp\DefaultIcon]
#="MyApplication.exe,1"
[HKEY_CLASSES_ROOT\myapp\shell]
#="open"
[HKEY_CLASSES_ROOT\myapp\shell\open]
#="Open with My Application"
[HKEY_CLASSES_ROOT\myapp\open\command]
#="\"C:\\Program Files (x86)\\My Application\\launcher.bat\" \"%1\""
What else should I add to the registry to do so?

First name your type:
assoc .<ext> <anyName>
And then set the program to open:
ftype <anyName>=<application-path>
Replace all names in angle-brackets with your names:
<ext>: the extension
<anyName>: a name, where windows knows wich program to use, you could assoc multiple times with different extensions
<application-path>: the filename of the program to open it.

After a few days of digging, I have found the solution:
The registry above assigns extension to the launcher (or any executable) to open it with, but the OS only shows the executable name as the associated program - which is fine, because It wasn't registred. This could be shown on the properties window of the file which are associated to, in exprorer, when you right click on the file and choose open with, and even in browesers when a URI scheme is registed.
To do so, the application has to be registred as well in the registry. After digging the internet, finally found on MSDN the extra registry changes that does so.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Applications\MyApplicationLauncher.bat]
FriendlyAppName = "My Application"
DefaultIcon = "<MyApplicationPath>\MyApplication.exe,1"
Note that using application names like launcher.bat or start.bat might cause conflicts; to prove its uniqueness, I had to rename it in the installer package to identify it.

Related

How do I create or modify a VB6 exe Version resource block to make it Squirrel-Aware

I have this crazy idea to take a large VB6 app we are continually migrating to .NET and use the Squirrel for Windows installer. It seems I need to make the VB6 app Squirrel-Aware as described here -- add VALUE "SquirrelAwareVersion", "1" to the Version resource block.
The problem is I'm very unfamiliar with rc files and there are only bits of documentation on the format, encodings, etc especially when working with VB6. I think I need a command line tool that can add this VALUE "SquirrelAwareVersion", "1" to the Version resource of an existing exe, OR figure out how to get VB6 to use a custom .res file with all the version data in it.
Most tools only seem to modify basic resource info like icons, manifests, and strings. I would need something capable of modifying or replacing this version data.
I've attempted to create a basic .rc. I make an empty file with the name MyApp.rc. Open the file with Visual Studio. Add a "Version" resource and attempt to compile it to .res with RC.exe but I get all sorts of errors from this file generated by Visual Studio. If I close and reopen the generated RC file, even Visual Studio can't open it. Could be an encoding problem? I'm not sure how else to create a valid RC file.
You can use Resource Hacker utility in CLI mode to replace whatever resources you need to in your final executable. It can even compile .rc files to .res file with something like this:
c:> ResourceHacker.exe -open Project1.rc -save Project1.res -action compile
Then use something like this on the command line to add new or replace existing resources from a .res file into your final executable:
c:> ResourceHacker.exe -open Project1.exe -save Project1.exe -action addoverwrite -resource Project1.res
Add -log NUL parameter to suppress console output if you need to.
Make a res file in VB6. VB6 only allows editing of certain things. Use ResHacker to add anything else you want to the Res file. VB6 add it's own version so you may need to do it to the exe file. http://www.angusj.com/resourcehacker/

Alternate keys as primary keys in windows resource kit

Is there a way to remap underscore (_) key to dash key (-) in windows resource kit remapkey tool?
Don't know about resource kit remapkey tool,
but this worked for me:
Download and install the latest version of https://www.autohotkey.com/.
Create a new script called underscore.ahk with your favorite text editor.
Write the following in the file and save it:
$_::Send, -
$-::Send, _
Double-click the file to run the script.
If you wish, copy the script (or a link to it) in the Startup folder.
Credits:
https://superuser.com/questions/419736/remapping-shift-space-to-an-underscore
https://www.autohotkey.com/boards/viewtopic.php?t=10328

Having Issues With EV Code Signing

I have recently purchased EV Code signing certificate from DigiCert...
Now i am having issues to sign my installer executable files.
Currently (Till now) below is the process to make the installer:
Step-1:
My installer is configured in a way so, it will load all common files from it's child support directory.
like below files structure:
Setup.exe (it's only have application exe file and few other configuration file that changes time to time)
Support (Directory)
Support\DLL (Has DLL files that is required by my application)
Support\Others (Any Other files)
Support\ETC (Just for example purpose)
All those support files is resided on my server as they don't change frequently
so, i have created a wrapper installer.exe file and a script to handle the wrapper..
That wrapper installer.exe file also resides on my server
Step-2:
My script does below steps:
a) make the setup.exe with the updated application files.
b) upload setup.exe file to server
c) add (append) that setup.exe and all others required files at the end of wrapper installer.exe file
d) I Provide That wrapper installer.exe (single file) to my clients/users.
Step-3:
When that wrapper executes, it creates a temp folder in temp directory. extract all the files that is appended in itself. and run the setup.exe from that temp directory
I make this process, as i only have to change application file that is few kilobytes only (always below 1mb), but those support files are huge in size.
So, instead of having to upload all those files from my local computer each time.
i make this wrapper process to make update/upload process much faster.
Now, The Problem:
If i sign the wrapper.exe file and put it to server, but when my script append data to that file, it looses the certificate settings (it's no longer signed :( )
so, how can i overcome this situation..
Update-1:
As asked, below is the php code that used to append setup.exe file:
//Appending Setup.exe file...
$archive_File = 'files/' . $strFileID . '.exe';
if (is_file($archive_File) == 1)
{
$strSize = filesize($archive_File);
$strData = 'Setup.exe' . chr(0) . $strSize . chr(0) . file_get_contents($archive_File) ;
file_put_contents($strArchiveFile, $strData, FILE_APPEND | LOCK_EX);
}
else
{
exit ('following file does not exits: ' . $archive_File);
}
best regards
You can't modify wrapper.exe after you've code signed it. That's the whole point of code-signing - to validate that a virus or other tampering didn't occur on the signed executable.
I'm not sure why you are code signing wrapper.exe first, then appending the files to it afterwards. You need to do the following steps:
Code sign setup.exe and all other binaries first except for wrapper.exe
Append setup.exe and all other files to wrapper.exe.
Then code-sign wrapper.exe after it's been fully built.
There are a lot of free tools that will generate a self-extracting archive that when run will prompt the user to run the setup.exe within it. 7Zip will do this for free.
But it sounds like you need to build your wrapper.exe on demand right before it's downloaded. If that's the case, add the code signing script to your server code that builds the final wrapper.exe

Where does Steam store library directories?

In Steam, we can configure multiple directories/folders where it will look for applications. It is found in the menu Steam->Settings->Downloads->STEAM LIBRARY FOLDERS dialog.
Where can I find those settings if I'm looking programatically from outside Steam?
I'm more interested in the location for the Windows client.
Found it. On Windows they are stored in C:\Program Files (x86)\Steam\SteamApps\libraryfolders.vdf, and you also have to add Steam's install folder C:\Program Files (x86)\Steam
Here's a sample Python script to extract the information:
import re
with open(r"C:\Program Files (x86)\Steam\SteamApps\libraryfolders.vdf") as f:
folders = [r"C:\Program Files (x86)\Steam"]
lf = f.read()
folders.extend([fn.replace("\\\\", "\\") for fn in
re.findall('^\s*"\d*"\s*"([^"]*)"', lf, re.MULTILINE)])
I found it here:
C:\Program Files (x86)\Steam\config\config.vdf
There's a line in that file:
"BaseInstallFolder_1" "{YourSteamLibraryFolder}"
So I just open it with Notepad then Ctrl+F search 'Base'.
If that line is not in there:
Open Steam. > Sign into you account. > 'Steam'. > 'Settings'.
Then click on 'Downloads'. > 'STEAM LIBRARY FOLDERS'.
Make an empty folder somewhere.
Click on 'ADD LIBRARY FOLDER'.
Browse to the empty folder you made. > Click on 'SELECT'.
If you then look at the config.vdf again; there should be a line like this:
"BaseInstallFolder_1" "{YourNewEmptySteamLibraryFolder}"
If Steam hasn't been installed in the default location in Windows, you can find it in the registry under HKEY_LOCAL_MACHINE, on path SOFTWARE\Wow6432Node\Valve\Steam. Here's how I found it in Kotlin:
private val steamFolder: File = File(WinRegistry.getString(
WinRegistry.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Wow6432Node\\Valve\\Steam",
"InstallPath"))
You can then find the libraryfolders.vdf and config.vdf files, as per the other answers.
In each of those library folders you'll find files called appmanifest_<id>.acf, where <id> is the id of the game (find it in Properties / Updates on Steam). If you're looking for a particular game, that will help to determine which folder the game is in, if there's more than one game install location.

Adding a user-defined language in Notepad++

I'm trying to add the syntax plugin for the Go programming language in Notepad++.
There is a repository for such user-defined languages. I downloaded and unzipped the Go files, which contained a README, a userDefinedLang_Go.xml, and go.xml.
I attempted to follow the instructions at the bottom of the page as follows. Since I am using Windows 7 (x64), my Notepad++ directory is "C:\Program Files (x86)\Notepad++".
Having not installed a user defined language before, I didn't have a userDefinedLang.xml file already, so I copied userDefinedLang_Go.xml into the root directory, and renamed it to remove the "_Go", making it userDefinedLang.xml.
I then copied go.xml into C:\Program Files (x86)\Notepad++\plugins\APIs\
This seems to be all of the steps necessary. However, when I open Notepad++, there is no "Go" near "Lang => User Defined", and there is no syntactic coloring on a .go file. Attempting to import via "View => User-Defined Dialogue => import" gives a "fail to import" error.
What am I doing wrong? I'm using a clean installation of Notepad++, which is version 6.1.8.
I had to put my userDefineLang.xml file in my AppData\Roaming folder:
C:\Users\[user]\AppData\Roaming\Notepad++
New install of Notepad++ 6.4.5 on Windows 7 64 bit
Download from Notepad++ site:
http://docs.notepad-plus-plus.org/index.php?title=User_Defined_Language_Files#G
Copy "go.xml" to C:\Program Files (x86)\Notepad++\plugins\APIs.
The default install doesn't have any user-defined languages, so you can do this:
Copy "userDefineLang_Go.xml" to C:\Users\\AppData\Roaming\Notepad++
Remove the "_Go" from the file name, so it's "userDefineLang.xml"
Uncomment the opening and closing "NotepadPlus" tags.
(If you already have a userDefineLang.xml then add the content from the _Go file.)
Restart Notepad++.
I just got it working on my system after some tinkering. Put this at the top of the userDefinedLang.xml file and the go.xml file:
<?xml version="1.0" encoding="Windows-1252" ?>
That should do the trick (after reopening Notepad++).
go.xml should be in the plugins/APIs folder, and userDefinedLang.xml goes in the root of Notepad++ as you said.
Something other answers do not discuss: Some older versions of Notepad++ do not appear to work with any of these answers.
I tried pretty much all the solutions before upgrading Notepad++ to version 6.4.2.
xkcd 979
Tested Notepad++ versions:
5.9 - not working - tested by namey
6.4.2 - working - tested by Elysian Fields
6.6.9 - working - tested by namey
For other versions your mileage may vary.
I share the solution I found for Notepad++ 6.5, because I had the same issue than the previous messages.
If not done, do the install steps explained in go\misc\notepadplus\README (userDefineLang.xml,functionList.xml,APIs).
When you don 't have useDefineLang.xml in Notepad++, create one using the file from go\misc\notepadplus\useDefineLang.xml, but don't forget to add the first line <?xml version="1.0" encoding="Windows-1252" ?>
and uncomment NotepadPlus part to have <NotepadPlus> at the beginning and </NotepadPlus> at the end.
Change in functionList.xml: <association ext=".go" id="go"/> BY <association userDefinedLangName="go" id="go"/>
As I didn't have any userDefineLang.xml file by default in Notepad++, I imported this file using the menu Language → Define your language → *Import.
Then stop/start Notepad++.
Check that Go is in the Language menu at the end of the list.
Open a .go file. If the color doesn't change automatically click on go in /Language menu
All were OK after that for me (indentation, color, autocompletion, etc.).
I added pl/sql language syntax to Notepad++. The syntax /language was on the web. Here's how I got it to work ...
Open the XML file using Notepad and added <?xml version="1.0" encoding="Windows-1252" ?> to the very beginning, as David had suggested. Then save it to userDefinedLang_plsql.xml
Paste the file in the Notepad++ root directory.
I also copied it into C:\Program Files (x86)\Notepad++\plugins\APIs\, and navigated to menu Languages → Userdefined, but it did nothing.
So, I then went to menu Languages → Define your language and selected pl/sql from the drop down, renamed it, and saved it in that dialog window.
The new language then it appeared in the language dialog at the end.
userDefineLang resides in C:\Users\username\AppData\Roaming\Notepad++\userDefineLang.xml.
Make sure your Notepad++ is installed under "C:\Program Files(86)", and not under "C:\npp.#.#.#.bin" folder.
And download from https://notepad-plus-plus.org/download. Or simply google "Download Notepad++".
Check out a sample Scala language userDefineLang.xml file here: https://github.com/nfang/scala-syntax-highlighter
If you don't have any user languages defined before, then after renaming userDefinedLang_Go.xml to userDefinedLang.xml, also edit the text of file by adding the tags <NotepadPlus></NotepadPlus> around the original content.

Resources