信息发布→ 登录 注册 退出

C++添加开机自启动的代码

发布时间:2025-07-09

点击量:

以下是使用javascript语言实现相同功能的伪原创代码,代码运行次数为0:

// JavaScript模拟实现开机自启动功能

// 定义注册表路径
const regPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
// 定义要启动的程序路径
const programPath = "C:\\Windows\\System32\\door.js";

// 模拟打开注册表
function openRegistry(path) {
    console.log(`Opening registry at ${path}`);
    return true; // 假设成功打开
}

// 模拟设置注册表值
function setRegistryValue(key, valueName, type, value) {
    console.log(`Setting registry value: ${valueName} = ${value}`);
    return true; // 假设成功设置
}

// 模拟复制文件
function copyFile(source, destination) {
    console.log(`Copying file from ${source} to ${destination}`);
    return true; // 假设成功复制
}

// 主函数
function main() {
    // 打开注册表
    if (openRegistry(regPath)) {
        // 设置注册表值
        if (setRegistryValue(regPath, "door", "REG_EXPAND_SZ", programPath)) {
            console.log("Successfully set run key");
        } else {
            console.log("Failed to set value");
            return;
        }
    }

    // 获取当前脚本路径
    const currentScriptPath = window.location.href;
    // 获取系统目录路径
    const systemDirectory = "C:\\Windows\\System32"; // 模拟系统目录

    // 复制文件到系统目录
    const destinationPath = systemDirectory + "\\door.js";
    if (copyFile(currentScriptPath, destinationPath)) {
        console.log(`${currentScriptPath} has been copied to ${destinationPath}`);
    } else {
        console.log("The file already exists");
    }
}

// 运行主函数
main();

效果图保持不变:

标签:# windows  # ai  # c++  # JavaScript  # 注册表  # 打开注册表  # 数为  # openRegistry  # console  # path  # function  # door  # js  # true  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!