-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.vbs
35 lines (28 loc) · 1.12 KB
/
install.vbs
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
31
32
33
34
35
Const OWN_PROCESS = &H10
Const ERR_CONTROL = &H2
Const INTERACTIVE = False
Const NET_FW_IP_PROTOCOL_TCP = 6
Const NET_FW_IP_PROTOCOL_UDP = 17
Const NET_FW_ACTION_ALLOW = 1
Const NET_FW_PROFILE2_ALL = 2147483647
InstallPath = Session.Property("CustomActionData")
ServiceName = "BethunexAgent"
DisplayName = "Bethunex Agent"
ExePath = InstallPath & "hive.exe"
ServicePort = 6142
Set ObjWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate, (Security)}!\\.\root\cimv2")
Set ObjSvr = ObjWMI.Get("Win32_Service")
Result = ObjSvr.Create(ServiceName, DisplayName, ExePath, OWN_PROCESS, ERR_CONTROL, "Automatic", INTERACTIVE, "LocalSystem", "")
Set ObjService = ObjWMI.Get("Win32_Service.Name='" & ServiceName & "'")
Result = ObjService.StartService()
Set FwPolicy2 = CreateObject("HNetCfg.FwPolicy2")
Set RulesObject = FwPolicy2.Rules
Set NewRule = CreateObject("HNetCfg.FWRule")
NewRule.Name = ServiceName
NewRule.Applicationname = ExePath
NewRule.Servicename = ServiceName
NewRule.Profiles = NET_FW_PROFILE2_ALL
NewRule.Enabled = TRUE
NewRule.InterfaceTypes = "All"
NewRule.Action = NET_FW_ACTION_ALLOW
RulesObject.Add NewRule