Closed chaoscreater closed 7 months ago
I got it working.
So the issue is that when you call a BATCH/CMD file, the URL that gets passed from the Open In extension will not be fully recognized by CMD for some reason. If the URL contains special characters, they need to be escaped properly before it gets passed into CMD. If not, then CMD will only be using a substring of the full URL.
I've tried to use Powershell in the executable path, but you need to also provide a file to the Powershell script, as you can't just provide a Powershell script in the form of "abc.ps1" as an executable to be used in the executable path.
The setting should really allow double quotes in the configuration, because that way you can actually specify arguments and filepaths properly.
Anyway, I created a workaround using Autohotkey. I've created a script to take whatever argument and open it in your default browser. The script will need to be compiled into an exe using Autohotkey, which is really quick and easy to do, but I'll provide the exe binary here as well. You then point the Open In setting to the AHK exe and everything works now.
I currently use Thorium portable, so the executable path for me would look something like this:
"D:\5. Portable Apps\1. Browsers\Thorium\BIN\thorium.exe" --user-data-dir="D:\5. Portable Apps\1. Browsers\Thorium\USER_DATA"
Problem is, you can't use quotes in the executable path for some reason, your extension just doesn't like it. Therefore, the only thing I can do here is this:
D:\5. Portable Apps\1. Browsers\Thorium\BIN\thorium.exe
While that works, it's not referencing the user profile path, which means it's actually loading a vanilla version of Thorium without any of my extensions and tabs etc and that's not good.
So then I came up with a workaround, use a BATCH script in the executable path instead, like this:
D:\5. Portable Apps\1. Browsers\Thorium\THORIUM.BAT
In the BAT file, I'm doing this:
start "" "D:\5. Portable Apps\1. Browsers\Thorium\BIN\thorium.exe" --user-data-dir="D:\5. Portable Apps\1. Browsers\Thorium\USER_DATA" --allow-outdated-plugins --disable-logging --disable-breakpad --disable-encryption --disable-machine-id -url '%*'
The key bit here is the URL argument at the end. In CMD/BATCH, you can pass in arguments as %*.
This works great, except that some URLs have special characters that need to be escaped. For example:
https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsparknz.service-now.com%2Fnav_to.do%3Furi%3Dsc_task.do%253Fsys_id%253D712d8xxxxxxxxxxx71258900153afd5&data=05%7C02%7CXXXXXX.xxxxxx%40xxxxxxxxxxxxx.co.nz%7C4553d46e7a7eyyyyyy83d08dc1d2f1cf0%7C90ssssss084727b3e7ec2b28440742%7C0%7C0%7C638417335430604765%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIixxxxxxxxLCJXVCI6Mn0%3D%yyyyy0%7C%7C%7C&sdata=%2BUkCdxxxxSaCJItkcvQGNqQcgekFnxxxxx2FOjlw%3D&reserved=0
The above won't be 100% passed to my BATCH script as is. What gets passed is actually: https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsparknz.service-now.com%2Fnav_to.do%3Furi%3Dsc_task.do%253Fsys_id%253D712d8xxxxxxxxxxx71258900153afd5
Do you have any ideas how I can fix this?