Open Local Program from the Start Page/ a Bookmark
-
Fell down a bit of a rabbit hole to get this working, but you can open a locally installed program from Vivaldi from a Start Page speed dial or a regular bookmark.
It is probably more trouble than it is worth, but here is how you do it...
URI Scheme and Handler Application
The first thing you need to set up a custom URI Scheme and register a handler application for it.
A URI Scheme is something that starts a URL/hyperlink that lets Vivaldi hand off an action to another application.
A common URI Scheme is
mailto:
which is accompanied with an email address to allow you to send an email to the address attached from your email client without needing to copy and paste the address over to the other program.--
The first step to getting a custom URI Scheme working for us is to set up the handler application (the email client program in the
mailto:
example).Steps For Windows
-
Create a new text file and converted to a PowerShell Script by changing
.txt
to.ps1
.
Edit: Old version usedBatch Script
, but lack of a proper way to sanitize input led to usingPowerShell Script
instead. -
Open it by right clicking it and selecting
Edit
and then paste this in to the top white input area:# define the input arg to be a URI param ( [ValidateScript({($_ -as [System.URI]).AbsoluteURI -ne $null})] [System.Uri]$arg ) # extract the program name from the url $name = $arg.Host # define paths to allowed programs # ************* START EDIT THESE VALUES************* $programs = @{ "calculator" = "C:\Users\VM\Desktop\Calculator - Shortcut.lnk"; "hangman" = "C:\Users\VM\Desktop\hangman.exe"; "weather" = "C:\Users\VM\Desktop\Weather - Shortcut.lnk"; } # *************END EDIT THESE VALUES************* # get the potential program's path $path = $programs[$name] # see if input it is an allowed program and has a path, and if so, run the program if (-not ([string]::IsNullOrEmpty($path))) { Start-Process -FilePath $path }
a. You will need to edit the section marked between the start and end
# *************EDIT THESE VALUES*************
. This is where you define which programs are able to run. For each program, you will need to include the name you will call later and the path to the program. Note: Spaces are not allowed in the name.For Example:
For a calculator program, I will later useexample://calculator
as a URL to call the program and I have a shortcut to the program with a path ofC:\Users\VM\Desktop\Calculator - Shortcut.lnk
, so between the curly braces{
and}
I will include this line"calculator" = "C:\Users\VM\Desktop\Calculator - Shortcut.lnk";
ย
Here is the generalized structure:"
programNameNoSpaces
" = "
path\to\the\program\executable\or\shortcut
";
ย
You can add as many programs as you want, just make sure each set is separated by a;
or is on a separate line. In the example I gave, I used both separate lines and;
's, but it isn't necessary to use both. -
Save the file and place it in a folder out of the way where it won't get accidentally deleted.
-
For the next steps, we will need the path to the
.ps1
file, so make a note of it for later. In this example, I will useC:\appurl.ps1
(I just chucked the file in C:\ for testing).
--
The next step in this process is registering the application handling the custom URI Scheme with Windows. This is done by adding keys to the registry with RegEdit.
I followed this guide provided by Microsoft: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)
This can be saved as a
.reg
file and launched to make the changes to the registry you need, but you will need to replace the path to match the value you saved from step 4 in the last section. You will also need to chose a URI Scheme name. I will be usingexample://
:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\example] @="URL:Vivaldi Program Launch example Protocol" "URL Protocol"="" [HKEY_CLASSES_ROOT\example\DefaultIcon] @="appurl.ps1,1" [HKEY_CLASSES_ROOT\example\shell] [HKEY_CLASSES_ROOT\example\shell\open] [HKEY_CLASSES_ROOT\example\shell\open\command] @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -ExecutionPolicy Bypass -File \"C:\\appurl.ps1\" \"%1\""
Every place you see
example
above, including the paths to the registry keys, you should replace with the name of the URI Scheme you chose.You also need to replace the path in the last registry key with the path to your
.ps1
file. Put a\
in front of slashes and spaces to escape them. Only change the part after-File
between the\"
and the\"
what is currentlyC:\\appurl.ps1
.--
That is all the background work done, so now you can move on to working in Vivaldi.
Setting Up the Speed Dial / Bookmark in Vivaldi
First I would like to thank @LonM and @Pathduck for their posts in this thread. It helped me get past some of the odd quirks I found along the way.
Unfortunately we can't just create a bookmark for
example://programName
and have it work. There are a few oddities that make that method unusable with Vivaldi.So here is the workaround method to get it to work:
-
Get the name of the program you set up in the
.ps1
file earlier that you want to launch (the first value in something like"calculator" = "C:\Users\VM\Desktop\Calculator - Shortcut.lnk";
. In this example, I am going to launch a simple command line hangman program I made that has the namehangman
-
Next you will need to edit the name of the program into this:
data:text/html,<html><body><script>window.location.href="example://hangman";window.history.back();</script></body></html>
a. You will need to change the URI Scheme to the one you created earlier. Mine was
example
, so after thewindow.location.href
, I putexample://
b. After the URI Scheme, you put the name of the program to launch.
c. You can remove the
window.history.back();
if you want. When you launch the program, it will bring up a blank page. All that that segment does is navigate back a page to have the Start Page visible again. -
Then you need to create a new bookmark, on the start page or elsewhere, and set the URL to what you got above.
-
Then, theoretically, you should be all set! When you launch the bookmark, you will need to select
Open
from the popup dialog.Apparently you used to be able to approve the application to run in the future, but a change to Chromium removed this option.(This is probably a good security feature in this case. I just got a bit annoyed with it in testing...)
GIF showing it working
ย
Too bad I am horrible at spelling and made the program pull a pseudo random word from an API. Dictionary.com doesn't have an entry forhishon
, so at least I didn't get "hung up" on a real word...
Sorry that I only included instructions for Windows. While I do have another VM with Linux, I am not invested enough in this functionality to figure out the specifics for other operating systems.
Hope someone is dedicated enough to add this to their setup
-
-
@nomadic Wow, that's some impressive hack!
Also dangerous - there are some very good security reasons why launching programs from browsers is generally considered a Bad Idea. In this case of course, you obviously know what you're doing and you also need a .bat file to make it work, but enabling the opening of a random program on the client could easily be abused by a malicious site.
I guess the above is why Chromium has made it so difficult to set application protocols and it requires user input.
I use both
magnet://
andsteam://
links regularly and of course these launch local programs. I do have the option for the browser to remember the option for the sites though, but I assume opening a .bat file might be a special caseI'm wondering - once you have the
example://
protocol working, it might be possible to use a custom menu entry in Vivaldi to launch a program. It could be a cool feature, although I've yet to see an actual use case for myself. -
As soon as I saw the title, I knew I had to try it!
This will be so cool once I finish it.
Edit: Whew! After being stupid for a while, I finally figured it out.
@nomadic is there a way to launch UWPs this way?
-
@legobuilder26 said in Open Local Program from the Start Page/ a Bookmark:
@nomadic is there a way to launch UWPs this way?
Yeah, looks like you can.
Steps adapted from here and here.
- Use the keyboard combo
Win
+R
and paste inshell:AppsFolder
and hitOK
. This will open a folder with all of the apps installed on your computer. - Find the app.
- Right Click and choose "Create Shortcut."
- Yes, placed the shortcut on desktop.
- Move the shortcut to a location out of the way where it won't accidentally get deleted.
- Use
Shift
+Right Click
on the app shortcut and selectCopy as Path
- You can then use that path like a normal one for an
exe
- Use the keyboard combo
-
@Pathduck Yeah, I have been thinking on this some, and there might be a safer way to handle things in the
.bat
file.While what I currently posted is safe through obscurity and requires the dialog confirmation, it is at least possible for something bad to happen. An extension, for example, could overwrite the URL to something else.
Off topic scenario
So one night you are staying up late working on a mod to add a "Doughnut
Button" to the status bar...
ย
You go over to StackOverflow for a question, but you end up getting into a heated debate with a sketchy user that argues not all donuts have holes, so the button doesn't make sense...
ย
Then some random new user sends you a link to an extension that solves your issue, so you install it...
ย
Turns out that sketchy user was a hacker that got mad at you...
ย
They went through all your post history and saw you had a way for your browser to launch external programs and they also saw you asked some questions about a program you made calleddeleteAllMyImportantNonBackedUpFiles.exe
...
ย
So they created a new account and wrote an extension to punish you for your blasphemous donut ideology...
ย
You want to calculate the circumference of the donut hole you are making, so you go to your speed dial to launch your calculator app bookmark you made...
ย
Only you didn't notice that the extension changed your bookmark's URL so that it now launchesdeleteAllMyImportantNonBackedUpFiles.exe
...
ย
Now your secret recipe for a jelly filled donut that still has a hole through the middle is lost foreverโ
ย ย
My proposed solution would be to use prepared commands.
So instead of
example://path/to/some/program/calculator.exe
the URL could beexample://calculator
and just add some logic to the.bat
file to supplement the appropriate path.Part of the methodology I used in the post was basically stolen from an AutoHotKey forum post I found. I didn't think AHK was necessary to complete the action, so I just converted it to a
.bat
file without thinking about it too much.I think I will now edit the original post to use prepared commands to be safer.
Also, I am not using this myself. I just saw this post and started wondering if there would be a way to do it.
-
@nomadic Love your off topic scenario
Thanks for the tips! -
New much safer version is out. It should now sanitized inputs and use prepared commands.
If I had more experience working with databases, then maybe the original version would have been better.
The more reading I did into making the Batch Script version safe, the more I didn't want to use a Batch Script anymore, so I abandoned it in favor of a PowerShell Script.
There was the issue that PowerShell Scripts can't run by default in Windows, but including
-ExecutionPolicy Bypass
when the script is called seems to fix that without opening up the system to run other PowerShell Scripts.
@legobuilder26 let me know if the instructions still make sense. In the process of adapting them from
.bat
to.ps1
, they seem to have become less clear. -
@nomadic said in Open Local Program from the Start Page/ a Bookmark:
@legobuilder26 let me know if the instructions still make sense. In the process of adapting them from .bat to .ps1, they seem to have become less clear.
makes sense to me