Windows 10 JavaScript Invoking a batch file using custom protocol fails

33 Views Asked by At

I created a new entry into the Registry (following this post). The entry is shown in the following snapshot:

Registry

Once this entry was defined, I used the following piece of code to verify that the Batch script is invoked from a JavaScript function:

Save_Result = async () => {
                        const location = window.location.hostname;
                        const settings = {
                                            method: 'POST',
                                            headers: {
                                                        Accept: 'application/json',
                                                        'Content-Type': 'application/text',
                                                     }
                                         };
                  try {
                  const fetchResponse = await fetch(`FDMyAlbsIF: "asdads" "dfgdfg" "dfgdfgert"` , settings);
        const data = await fetchResponse.text;
        return data;
    } catch (e) {
        return e;
    }    
}
Save_Result () ;

Obviously, I'm not doing things correctly as I got the following error message:

Fetch API cannot load fdmyalbsif: "asdads" "dfgdfg" "dfgdfgert". URL scheme "fdmyalbsif" is not supported.

The question is what am I doing wrong?

1

There are 1 best solutions below

0
FDavidov On

I was able to create the correct Custom Protocol definition into the Registry (It works when using it in Windows Explorer as suggested by David above) and it works. There are still some issues to tackle though (see this post).