浏览器启动exe程序,是通过程序注册要注册表,然后页面访问即可;
我已经写好了,
"首次激活.bat":静态注册表到系统
"启动.html":启动程序即可;
"ltReg":目录下是".reg"注册表,可以执行运行的
要改自己的程序就改html,和ltReg/下的ltapp1.reg路径文件哦
看效果
这是第一个程序ltapp1.reg 内容,改ltapp1字眼和最后路径即可
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ltapp1]
@="URL:app"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\ltapp1\shell]
[HKEY_CLASSES_ROOT\ltapp1\shell\open]
[HKEY_CLASSES_ROOT\ltapp1\shell\open\command]
@="\"%LTAPP_PATH%\"\\软件1\\Mconsole.exe"
首次激活.bat内容:这里是批量注册到系统,我这里是固定5个
@echo off
chcp 65001 >nul
cd /d %~dp0
fltmc >nul 2>&1 || (
echo 请以管理员身份运行此脚本!
pause
exit /b 1
)
echo 当前目录: %cd%
set LTAPP_PATH=%cd%
echo 设置 LTAPP_PATH 为: %LTAPP_PATH%
:: 创建临时注册表文件并替换路径
for %%a in (1 2 3 4 5) do (
powershell -Command "$path = '%LTAPP_PATH%'; $doublePath = $path.Replace('\', '\\'); $content = Get-Content 'ltReg\\ltapp%%a.reg' -Encoding Default; $newContent = $content.Replace('%%LTAPP_PATH%%', $doublePath).Replace('\\\"' + $doublePath + '\\\"', $doublePath); Set-Content 'ltReg\\ltapp%%a_temp.reg' $newContent -Encoding Default"
regedit /s "ltReg\\ltapp%%a_temp.reg"
del "ltReg\\ltapp%%a_temp.reg"
)
echo 注册表导入完成!
echo 启动浏览器!
echo start 启动.html
echo pause
html内容
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>产品中心 - 应用启动器</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Microsoft YaHei', sans-serif;
}
body {
display: flex;
min-height: 100vh;
background-color: #f5f7fa;
color: #333;
}
/* 左侧导航样式 */
.sidebar {
width: 250px;
background: linear-gradient(135deg, #2c3e50, #1a2530);
color: white;
padding: 20px 0;
box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
}
.logo {
text-align: center;
padding: 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
margin-bottom: 30px;
}
.logo h1 {
font-size: 22px;
margin-top: 10px;
}
.logo-img {
width: 80px;
height: 80px;
border-radius: 50%;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
font-size: 30px;
color: white;
}
.nav-item {
padding: 15px 30px;
margin: 5px 0;
cursor: pointer;
transition: all 0.3s;
display: flex;
align-items: center;
}
.nav-item.active {
background-color: #3498db;
border-left: 4px solid #fff;
}
.nav-item:hover {
background-color: #2c3e90;
}
/* 右侧内容区域 */
.content {
flex: 1;
padding: 30px;
overflow-y: auto;
}
.page-title {
margin-bottom: 30px;
color: #2c3e50;
border-bottom: 2px solid #3498db;
padding-bottom: 10px;
display: inline-block;
}
/* 产品卡片样式 */
.products-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 25px;
}
.product-card {
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
transition: transform 0.3s, box-shadow 0.3s;
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}
.product-image {
height: 180px;
display: flex;
align-items: center;
justify-content: center;
background: transparent !important;
position: relative;
overflow: hidden;
}
.product-image::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(135deg, rgba(238, 242, 247, 0.7), rgba(214, 219, 223, 0.7));
z-index: 1;
}
.product-image img {
max-width: 80%;
max-height: 80%;
object-fit: contain;
z-index: 2;
position: relative;
filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.1));
}
.product-info {
padding: 20px;
}
.product-name {
font-size: 18px;
font-weight: bold;
margin-bottom: 5px;
color: #2c3e50;
}
.product-version {
color: #7f8c8d;
margin-bottom: 15px;
font-size: 14px;
}
.launch-btn {
display: block;
width: 100%;
padding: 12px;
background: linear-gradient(to right, #3498db, #2980b9);
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: all 0.3s;
box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
}
.launch-btn:hover {
background: linear-gradient(to right, #2980b9, #2573a7);
box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}
/* 默认图标样式 */
.default-icon {
width: 80px;
height: 80px;
background: linear-gradient(135deg, #3498db, #2c3e50);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 14px;
font-weight: bold;
text-align: center;
z-index: 2;
position: relative;
}
/* 响应式设计 */
@media (max-width: 768px) {
body {
flex-direction: column;
}
.sidebar {
width: 100%;
padding: 10px 0;
}
.products-container {
grid-template-columns: 1fr;
}
.search-bar {
flex-direction: column;
}
}
</style>
</head>
<body>
<!-- 左侧导航 -->
<div class="sidebar">
<div class="logo">
<div class="logo-img">
<img src="ltReg/lt.png" style="border-radius: 50%;width: 100px;" alt="Logo">
</div>
</div>
<div class="nav-item active">产品中心</div>
</div>
<!-- 右侧内容区域 -->
<div class="content">
<h2 class="page-title">产品中心</h2>
<!-- 产品卡片容器 -->
<div class="products-container" id="productsContainer">
<!-- 产品卡片将由JavaScript动态生成 -->
</div>
</div>
<script>
// 产品数据集合
const products = [
{
id: 1,
name: "Mconsole 控制台",
version: "V2.8.30.1_DBG",
image: "软件1/img/main.ico",
protocol: "ltapp1"
},
{
id: 2,
name: "设计工具",
version: "1.0.3",
image: "软件2/img/main.ico",
protocol: "ltapp2"
},
{
id: 3,
name: "数据分析器",
version: "3.4.0",
image: "软件3/img/main.ico",
protocol: "ltapp3"
},
{
id: 4,
name: "文件管理器",
version: "1.2.7",
image: "软件4/img/main.ico",
protocol: "ltapp4"
},
{
id: 5,
name: "文件管理器5",
version: "1.2.7",
image: "软件5/img/main.ico",
protocol: "ltapp5"
}
];
// 渲染产品卡片
function renderProducts() {
const container = document.getElementById('productsContainer');
container.innerHTML = '';
// 渲染产品卡片
products.forEach(product => {
const card = document.createElement('div');
card.className = 'product-card';
card.dataset.id = product.id;
card.innerHTML = `
<div class="product-image">
<img src="${product.image}" alt="${product.name}图标" onerror="handleImageError(this, '${product.name}')">
</div>
<div class="product-info">
<div class="product-name">${product.name}</div>
<div class="product-version">版本: ${product.version}</div>
<button class="launch-btn" data-protocol="${product.protocol}">启动应用</button>
</div>
`;
container.appendChild(card);
});
}
// 图片加载失败处理
function handleImageError(img, productName) {
img.style.display = 'none';
const parent = img.parentElement;
parent.innerHTML = `<div class="default-icon">${productName.substring(0, 2)}</div>`;
}
// 启动应用函数
function launchApp(protocol) {
try {
// 使用自定义协议调起应用
window.location.href = `${protocol}://`;
// 显示提示信息
setTimeout(() => {
alert(`正在启动应用程序...`);
// 标记为最近使用
const product = products.find(p => p.protocol === protocol);
if (product) {
product.recent = true;
// 如果需要,可以保存到localStorage
}
}, 100);
} catch (e) {
alert('启动应用时出错: ' + e.message);
}
}
// 初始化函数
function init() {
// 初始渲染产品
renderProducts();
// 使用事件委托处理启动按钮点击
document.getElementById('productsContainer').addEventListener('click', (e) => {
if (e.target.classList.contains('launch-btn')) {
const protocol = e.target.dataset.protocol;
launchApp(protocol);
}
});
}
// 页面加载完成后初始化
document.addEventListener('DOMContentLoaded', init);
</script>
</body>
</html>
源码分享:浏览器启动exe.zip