I successfully defined into the Registry a Custom protocol (named FDMyAlbsIF). The protocol is aimed to invoke a Batch File that performs different actions depending on the received parameters.
I face two problems right now:
When invoking the protocol via Windows Explorer (i.e. entering into the path field the string
FDMyAlbsIF:\\ AAA BBB CCC), the batch file is indeed invoked and its actions are seen (right now I just echo into a file the received command with whatever parameters are entered). When invoked from JavaScript, I get and error message that reads:Fetch API cannot load fdmyalbsif:\ "AAA" "BBB" "CCC". URL scheme "fdmyalbsif" is not supported.When checking the contents of the tempo file, I see that the parameters are not passed the way I need since it is showing
"fdmyalbsif:\\%20AAA%20BBB%20TTT" "" "" ""
The definitions of the protocol within the Registry are:
reg add HKEY_CLASSES_ROOT\FDMyAlbsIF /t REG_SZ /d "My Description" /f
reg add HKEY_CLASSES_ROOT\FDMyAlbsIF /v "URL Protocol" /t REG_SZ /d "" /f
reg add HKEY_CLASSES_ROOT\FDMyAlbsIF\shell /f
reg add HKEY_CLASSES_ROOT\FDMyAlbsIF\shell\open /f
reg add HKEY_CLASSES_ROOT\FDMyAlbsIF\shell\open\command /t REG_SZ /d d:\MiAlbs\Manipulate_Files.bat "%1" "%2" "%3" "%4" /f
The code I use within the JavaScript to invoke the Batch File is:
Save_Result = async () => {
const location = window.location.hostname;
const settings = {
method: 'POST',
headers: {
Accept: 'application/text',
'Content-Type': 'application/text',
}
};
try {
const fetchResponse = await fetch(`FDMyAlbsIF:\\ "AAA" "BBB" "CCC"` , settings);
const data = await fetchResponse.text;
return data;
} catch (e) {
return e;
}
}
Save_Result () ;
My guess is that the use of post is inconsistent with the Custom Protocol, but I don't quite know how to phrase this request.
Edit
One more thing that may be important: When invoking the Batch File, there are some cases where one of the parameters is a multi-line string. I need this string to be received into the Batch File as-is.