Skip to content

Commit 1cdee86

Browse files
committed
msi: create event source for OpenVPNService
This enables OpenVPNService, running under limited virtual service account, to log to event log. GitHub: OpenVPN/openvpnserv2#27 Signed-off-by: Lev Stipakov <[email protected]>
1 parent ccd0a4e commit 1cdee86

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

windows-msi/msi.wxs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<Binary Id="Service.js" SourceFile="script\Service.js"/>
8686
<Binary Id="PlapReg.js" SourceFile="script\PlapReg.js"/>
8787
<Binary Id="ACL.js" SourceFile="script\ACL.js"/>
88+
<Binary Id="RegisterEventSource.js" SourceFile="script\RegisterEventSource.js"/>
8889

8990
<CustomAction Id="GetInstallDirForPlap" BinaryKey="PlapReg.js" JScriptCall="GetInstallDir" />
9091
<CustomAction Id="UpdatePlapReg" BinaryKey="PlapReg.js" JScriptCall="UpdatePlapReg" Execute="deferred" Impersonate="no" />
@@ -95,6 +96,7 @@
9596
<CustomAction Id="GetInstallDirForACL" BinaryKey="ACL.js" JScriptCall="GetInstallDir" Return="check" />
9697
<CustomAction Id="SetACL" BinaryKey="ACL.js" JScriptCall="SetACL" Execute="deferred" Impersonate="no" Return="check" />
9798

99+
<CustomAction Id="RegisterEventSource" BinaryKey="RegisterEventSource.js" JScriptCall="RegisterEventSource" Execute="deferred" Impersonate="no" Return="check" />
98100
<!--
99101
Detect system information
100102
-->
@@ -110,6 +112,7 @@
110112
<Custom Action="UpdatePlapReg" After="InstallFiles"/>
111113
<Custom Action="GetInstallDirForACL" After="SetProductDirParam">NOT Installed</Custom>
112114
<Custom Action="SetACL" After="InstallFiles">NOT Installed</Custom>
115+
<Custom Action="RegisterEventSource" After="InstallFiles">NOT Installed</Custom>
113116
</InstallExecuteSequence>
114117
<UI>
115118
<ProgressText Action="FindSystemInfo">Detecting system information</ProgressText>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function RegisterEventSource() {
2+
var shell = new ActiveXObject("WScript.Shell");
3+
var source = "OpenVPNService";
4+
var logName = "Application";
5+
6+
var command = 'powershell -ExecutionPolicy Bypass -Command "if (-not [System.Diagnostics.EventLog]::SourceExists(\'' +
7+
source + '\')) {[System.Diagnostics.EventLog]::CreateEventSource(\'' +
8+
source + '\', \'' + logName + '\')}"';
9+
10+
shell.Run(command, 0, true); // 0 = hidden, true = wait until complete
11+
}

0 commit comments

Comments
 (0)