This batch script starts the MSSQLLocalDB instance (if not already running), retrieves its named pipe connection string, updates the Windows Registry to point HeidiSQL to it, and finally launches HeidiSQL.
@echo off
REM Start LocalDB instance (if not already running)
sqllocaldb start MSSQLLocalDB
REM Get the named pipe connection string
FOR /f "tokens=2*delims=::" %%a IN ('sqllocaldb info MSSQLLocalDB') DO (
IF "%%a"==" np" SET "pipename=%%b"
)
echo %pipename%
REM Write pipe name as host in registry for HeidiSQL connection
REG ADD "HKEY_CURRENT_USER\Software\HeidiSQL\Servers\Localdb" /v "Host" /t REG_SZ /d "%pipename%" /f
echo Registry updated successfully.
REM Launch HeidiSQL
start "" "C:\Program Files\HeidiSQL\heidisql.exe"💡 Tip: Ensure you’ve already created a "Localdb" server configuration in HeidiSQL beforehand, so this registry update maps correctly.