-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaddto-startup.vbs
More file actions
30 lines (27 loc) · 2.25 KB
/
addto-startup.vbs
File metadata and controls
30 lines (27 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Option Explicit
Dim wsh, fso, link, BtnCode, ScriptDir, FilePaths, i
Set wsh = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Function CreateShortcut(FilePath)
Set wsh = WScript.CreateObject("WScript.Shell")
Set link = wsh.CreateShortcut(wsh.SpecialFolders("Startup") + "\goproxy.lnk")
link.TargetPath = FilePath
link.Arguments = ""
link.WindowStyle = 7
link.Description = "GoProxy"
link.WorkingDirectory = wsh.CurrentDirectory
link.Save()
End Function
BtnCode = wsh.Popup("是否将 goproxy.exe 加入到启动项?(本对话框 6 秒后消失)", 6, "GoProxy 对话框", 1+32)
If BtnCode = 1 Then
ScriptDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
FilePaths = Array(ScriptDir + "\goproxy-gui.exe", ScriptDir + "\goproxy.exe")
For i = 0 to ubound(FilePaths)
If Not fso.FileExists(FilePaths(i)) Then
wsh.Popup "当前目录下不存在 " + FilePaths(i), 5, "GoProxy 对话框", 16
WScript.Quit
End If
Next
CreateShortcut(FilePaths(0))
wsh.Popup "成功加入 GoProxy 到启动项", 5, "GoProxy 对话框", 64
End If