I want to set up my Lain terminal to have links that can open wIntegrate sessions. On windows this means that I have to register the wic protocol and set it up to call wintegrate.
A registered protocol handler will get the wic://123
as the argument and from there it can be parsed into the various pieces. For example, I'm planning to strip out the wic portion and then pass the remainder to wintegrate to try and open it.
The first step is to create the script that is going to do the launching of wIntegrate.
Once the script is set up, the final and most important step is to set the registry keys so that you can associate wic://
with the newly created script.
The batch script works but it pops up the command prompt when running. The start function closes the script once wintegrate is launched which is good but ideally the command prompt never appears.
@echo off
setlocal
setlocal enabledelayedexpansion
:: Remove the "wic://" prefix from the URL
set "url=%~1"
set "url=%url:wic://=%"
set url=!url:%%3A=:!
echo %url%
:: Check if file exists
if not exist "%url%" (
echo Error: File not found - "%url%"
exit /b 1
)
:: Launch wInteg.exe with the extracted file path
start "C:\Program Files (x86)\wIntegrate\wInteg.exe" "%url%"
endlocal
This can be saved in a .reg
file and then can be executed.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\wic]
@="URL:wic Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\wic\shell]
[HKEY_CLASSES_ROOT\wic\shell\open]
[HKEY_CLASSES_ROOT\wic\shell\open\command]
@="\"C:\\bin\\wic-handler.vbs\" \"%1\""
Once the registry key is loaded, you should now be able to test from the command line by doing:
>start wic://C:/Users/Username/sessions/session.wic
Now with the script and registry key working, I can now add links to a web page that look like:
<a href="wic://C%3A/sessions/session1.wic">Session 1</a>
Now when I click that link it will open my Session 1 with wIntegrate.
The original version was a batch script but this results in the command prompt window being created. I translated the program to vbs so that wouldn't happen.
The VBS script has an issue that it may require admin privilges and so currently I'm using the batch version.
The program takes the first argument and removes the wic://
. It also will conver the %3A
to colons. This is currently the only escaping done.
It will then check if it exists and if it does it will launch it with wIntegrate.
Dim url
url = WScript.Arguments(0)
url = Replace(url, "wic://", "")
url = Replace(url, "%3A", ":")
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists(url) Then
MsgBox "Error: File not found - " & url, 16, "File Not Found"
WScript.Quit(1)
End If
Set shell = CreateObject("WScript.Shell")
shell.Run """C:\Program Files (x86)\wIntegrate\wInteg.exe """ & url, 4, False
The key difference between this and the batch script is that the vbs script can run invisibly.