上一主题 下一主题
ScriptCat,新一代的脚本管理器脚本站,与全世界分享你的用户脚本油猴脚本开发指南教程目录
返回列表 发新帖

frp如何设置vbs自启动

[复制链接]
  • TA的每日心情
    开心
    2023-2-28 23:59
  • 签到天数: 191 天

    [LV.7]常住居民III

    632

    主题

    5168

    回帖

    6046

    积分

    管理员

    非物质文化遗产社会摇传承人

    积分
    6046

    荣誉开发者管理员油中2周年生态建设者喜迎中秋

    发表于 2023-3-29 18:33:34 | 显示全部楼层 | 阅读模式

    提示

    注意,该方法必须进入电脑桌面才可以运行
    如果是服务器必须远程登陆一次才可以
    一种其他方向疑似可以考虑nssm,但是未经尝试

    vbs申请权限之后设置注册表
    reg_start_up.vbs

    Set WShell = WScript.CreateObject("WScript.Shell")
    set fso =CreateObject("Scripting.FileSystemObject")
    tFile = "C:\Windows\System32\drivers\etc\test.txt"
    WShell.run("%comspec% /c echo 123> " & tFile), 0, True
    if not fso.FileExists(tFile) then
        CreateObject("Shell.Application").ShellExecute WScript.FullName, Chr(34) & WScript.ScriptFullName & Chr(34), "", "runas", 1
        WScript.Quit
    else
        fso.DeleteFile(tFile)
    End if
    runVbsPath=replace(WScript.ScriptFullName,"\reg_start_up.vbs","\start_frpc.vbs")
    WShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\frpVbsScript",runVbsPath,"REG_SZ"
    MsgBox("set window start up run have success")

    其中start_frpc.vbs改为绝对路径
    start_frpc.vbs

       Set ws = CreateObject("Wscript.Shell") 
       directPath=replace(WScript.ScriptFullName,"start_frpc.vbs","")
       runPath=directPath+"frpc.exe -c "+directPath+"frpc.ini"
       ws.run runPath,vbhide 
       Set ws=NoThing
       WScript.quit

    删除开机启动也比较简单

    Set WShell = WScript.CreateObject("WScript.Shell")
    set fso =CreateObject("Scripting.FileSystemObject")
    tFile = "C:\Windows\System32\drivers\etc\test.txt"
    WShell.run("%comspec% /c echo 123> " & tFile), 0, True
    if not fso.FileExists(tFile) then
        CreateObject("Shell.Application").ShellExecute WScript.FullName, Chr(34) & WScript.ScriptFullName & Chr(34), "", "runas", 1
        WScript.Quit
    else
        fso.DeleteFile(tFile)
    End if
    WShell.RegDelete( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\frpVbsScript")
    MsgBox("delete window start up run have success")
    混的人。
    ------------------------------------------
    進撃!永遠の帝国の破壊虎---李恒道

    入驻了爱发电https://afdian.net/a/lihengdao666
    个人宣言:この世界で私に胜てる人とコードはまだ生まれていません。死ぬのが怖くなければ来てください。

    发表回复

    本版积分规则

    快速回复 返回顶部 返回列表