李恒道 发表于 2023-3-29 18:33:34

frp如何设置vbs自启动

# 提示
注意,该方法必须进入电脑桌面才可以运行
如果是服务器必须远程登陆一次才可以
一种其他方向疑似可以考虑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")
```
页: [1]
查看完整版本: frp如何设置vbs自启动