From 1cdee86d9b1f190d4720fda37951ce119b528f2b Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Tue, 24 Jun 2025 12:50:07 +0200 Subject: [PATCH] msi: create event source for OpenVPNService This enables OpenVPNService, running under limited virtual service account, to log to event log. GitHub: https://github.com/OpenVPN/openvpnserv2/pull/27 Signed-off-by: Lev Stipakov --- windows-msi/msi.wxs | 3 +++ windows-msi/script/RegisterEventSource.js | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 windows-msi/script/RegisterEventSource.js diff --git a/windows-msi/msi.wxs b/windows-msi/msi.wxs index 3b6b367e..d892cee0 100644 --- a/windows-msi/msi.wxs +++ b/windows-msi/msi.wxs @@ -85,6 +85,7 @@ + @@ -95,6 +96,7 @@ + @@ -110,6 +112,7 @@ NOT Installed NOT Installed + NOT Installed Detecting system information diff --git a/windows-msi/script/RegisterEventSource.js b/windows-msi/script/RegisterEventSource.js new file mode 100644 index 00000000..de827a44 --- /dev/null +++ b/windows-msi/script/RegisterEventSource.js @@ -0,0 +1,11 @@ +function RegisterEventSource() { + var shell = new ActiveXObject("WScript.Shell"); + var source = "OpenVPNService"; + var logName = "Application"; + + var command = 'powershell -ExecutionPolicy Bypass -Command "if (-not [System.Diagnostics.EventLog]::SourceExists(\'' + + source + '\')) {[System.Diagnostics.EventLog]::CreateEventSource(\'' + + source + '\', \'' + logName + '\')}"'; + + shell.Run(command, 0, true); // 0 = hidden, true = wait until complete +}