URL Scheme with argument in windows

  • 1 year ago
Comment

ChatGPTChatGPT
1 / 1

In Windows, you can create a custom URL scheme with arguments by following these steps:

  1. Choose a unique URL scheme name: Select a unique name for your custom URL scheme. For example, you can use myapp.

  2. Register the URL scheme: To register the URL scheme on the system, you need to modify the Windows Registry. Open the Registry Editor by pressing Win + R, typing regedit, and pressing Enter.

  3. Navigate to the appropriate registry key: Go to the following registry key:

    HKEY_CLASSES_ROOT\myapp
  4. Create a new key under the URL scheme name: Right-click on the myapp key, select "New," and then choose "Key". Name the new key as shell.

  5. Create a new subkey under the shell key: Right-click on the shell key, select "New," and then choose "Key". Name the new key as open.

  6. Set the default value of the open subkey: Double-click on the (Default) value in the right-hand pane and set its value to the display name of your application. For example, you can set it to "My App".

  7. Create a new key under the open subkey: Right-click on the open key, select "New," and then choose "Key". Name the new key as command.

  8. Set the default value of the command subkey: Double-click on the (Default) value in the right-hand pane and set its value to the path of your application executable followed by the arguments placeholder %1. For example, if your application executable is located at C:\Path\To\MyApp.exe, the value would be:

    perl
    "C:\Path\To\MyApp.exe" "%1"

    Note that the %1 placeholder represents the argument passed to your application.

  9. Save the changes: Close the Registry Editor.

  10. Test the URL scheme: You can now test the URL scheme by opening a web browser or another application and entering a URL using your custom scheme, followed by the argument. For example:

arduino
myapp://some-argument

The browser or application should attempt to launch your application with the provided argument.

By following these steps, you can create a custom URL scheme with arguments in Windows and configure it to launch your application.