diff --git a/fluent-package/Rakefile b/fluent-package/Rakefile
index 5b1b37912..3fb7a4449 100755
--- a/fluent-package/Rakefile
+++ b/fluent-package/Rakefile
@@ -539,6 +539,7 @@ class BuildTask
cp("msi/assets/#{PACKAGE_NAME}-prompt.bat", fluent_package_staging_dir)
cp("msi/assets/#{PACKAGE_NAME}-post-install.bat", staging_bindir)
cp("msi/assets/#{PACKAGE_NAME}-post-migration.bat", staging_bindir)
+ cp("msi/assets/#{PACKAGE_NAME}-post-fluentdwinsvc.rb", staging_bindir)
cp("msi/assets/#{SERVICE_NAME}.bat", fluent_package_staging_dir)
cp("msi/assets/fluent-gem.bat", fluent_package_staging_dir)
cp("msi/assets/#{PACKAGE_NAME}-version.rb", staging_bindir)
diff --git a/fluent-package/msi/assets/fluent-package-post-fluentdwinsvc.rb b/fluent-package/msi/assets/fluent-package-post-fluentdwinsvc.rb
new file mode 100644
index 000000000..196e16a91
--- /dev/null
+++ b/fluent-package/msi/assets/fluent-package-post-fluentdwinsvc.rb
@@ -0,0 +1,37 @@
+require 'fileutils'
+require "win32/service"
+require "win32/registry"
+require "optparse"
+include Win32
+
+install_dir = "#{ARGV[0]}"
+
+default_fluentdwinsvc = "-c '#{install_dir}etc\\fluent\\fluentd.conf' -o '#{install_dir}fluentd.log'"
+registry_key = "SYSTEM\\CurrentControlSet\\Services\\fluentdwinsvc"
+
+puts("fluentdwinsvc default: #{default_fluentdwinsvc}")
+begin
+ Win32::Registry::HKEY_LOCAL_MACHINE.open(registry_key, Win32::Registry::KEY_ALL_ACCESS) do |reg|
+ # Check whether RegValue exists or not
+ puts("fluentdwinsvc registry key was opened: #{registry_key}")
+ begin
+ previous_fluentdopt = reg['fluentdopt', Win32::Registry::REG_SZ]
+ puts("fluentdwinsvc current value: #{previous_fluentdopt}")
+ if previous_fluentdopt != default_fluentdwinsvc
+ puts("fluentdwinsvc: fluentdopt configuration was kept because option was changed from default")
+ else
+ puts("fluentdwinsvc: fluentdopt configuration was same as default one: #{default_fluentdwinsvc}")
+ end
+ rescue Win32::Registry::Error
+ # As fluentdopt value does not exist, then set default configuration
+ puts("fluentdwinsvc: reset to default fluentdopt configuration")
+ reg['fluentdopt', Win32::Registry::REG_SZ] = default_fluentdwinsvc
+ end
+ end
+rescue Win32::Registry::Error
+ # No fluentdwinsvc key yet.
+ puts("fluentdwinsvc: create #{registory_key} and set default fluentdopt configuration")
+ Win32::Registry::HKEY_LOCAL_MACHINE.create(registory_key, Win32::Registry::KEY_ALL_ACCESS) do |reg|
+ reg['fluentdopt', Win32::Registry::REG_SZ] = default_fluentdwinsvc
+ end
+end
diff --git a/fluent-package/msi/source.wxs b/fluent-package/msi/source.wxs
index faeb7f1b7..4f3a1a372 100644
--- a/fluent-package/msi/source.wxs
+++ b/fluent-package/msi/source.wxs
@@ -185,7 +185,7 @@
+ Value=""[FLUENTPROJECTLOCATION]fluentd.bat" --reg-winsvc i --reg-winsvc-delay-start"/>
+
+
+
+
WIX_UPGRADE_DETECTED
WIX_UPGRADE_DETECTED
- NOT Installed
+ NOT Installed
NOT Installed
+ NOT Installed OR WIX_UPGRADE_DETECTED
+ NOT Installed OR WIX_UPGRADE_DETECTED
+
NOT Installed
NOT Installed
NOT Installed