Windows Agent resets its configuration in C:\ProgramData\checkmk\agent at every restart

CMK version: Checkmk Raw Edition 2.4.0p5
OS version: Windows Server 2012 R2 Standard

I have a weird problem with the checkmk agent for Windows (in my case specifically Windows Server 2012 R2).

After a restart of the service all the configuration and the plugins in the folder C:\ProgramData\checkmk\agent are gone. The agent seems to reset itself to the factory defaults.

On the Windows Server 2012 machine I could not register the service the normal way, so I did a proxy-register on another host and then copied and imported the respective JSON file.
After this everything works fine, even with the mk_oracle Plugin.
But every time the agents gets restarted everything is gone. The registered_connections.json, the plugin and its config etc.

I installed the agent normally by downloading the .msi file and just double clicked it.

I tried to install the agent on my work PC just out of curiosity without registering it with any site and I get the same behavior. Any file I put into C:\ProgramData\checkm\agent gets removed after a restart of the service.
(Here I can understand the behavior because without a working connection maybe the agent just resets itself every time).
But on the production machine I DO have a working connection to the checkmk server.

The output of cmk-agent-ctl status and check_mk_agent.exe showconfig ps look normal to me:

PS C:\Program Files (x86)\checkmk\service> & "C:/Program Files (x86)/checkmk/service/check_mk_agent.exe" showconfig ps
# Environment Variables:
# MK_LOCALDIR="C:\ProgramData\checkmk\agent\local"
# MK_STATEDIR="C:\ProgramData\checkmk\agent\state"
# MK_PLUGINSDIR="C:\ProgramData\checkmk\agent\plugins"
# MK_TEMPDIR="C:\ProgramData\checkmk\agent\tmp"
# MK_LOGDIR="C:\ProgramData\checkmk\agent\log"
# MK_CONFDIR="C:\ProgramData\checkmk\agent\config"
# MK_SPOOLDIR="C:\ProgramData\checkmk\agent\spool"
# MK_INSTALLDIR="C:\ProgramData\checkmk\agent\install"
# MK_MSI_PATH="C:\ProgramData\checkmk\agent\update"
# MK_MODULESDIR="C:\ProgramData\checkmk\agent\modules"
# Loaded Config Files:
# system: 'C:\Program Files (x86)\checkmk\service\check_mk.yml'
# bakery: 'C:\ProgramData\checkmk\agent\bakery'
# user  : 'C:\ProgramData\checkmk\agent\check_mk.user.yml'

enabled: yes
use_wmi: yes
full_path: no

PS C:\Program Files (x86)\checkmk\service> & "C:\Program Files (x86)\checkmk\service\cmk-agent-ctl" status
Version: 2.4.0p5
Agent socket: operational
IP allowlist: any


Imported connection:
        UUID: 962bd363-de7b-4b7f-ba3b-d8a758f94936
        Local:
                Connection mode: pull-agent
                Connecting to receiver port: None (imported connection)
                Certificate issuer: Site 'LiveDesign' agent signing CA
                Certificate validity: Thu, 03 Jul 2025 06:38:04 +0000 - Wed, 03 Jul 2030 06:38:04 +0000
        Remote:
                No remote address (imported connection)

Here is also the beginning of the logfile after a restart of the service:

2025-07-04 10:25:39.945 [srv 3184] [Trace] Enabled Base
2025-07-04 10:25:39.949 [srv 3184] [Trace] Setting root. service: 'CheckMkService', preset: ''
2025-07-04 10:25:39.950 [srv 3184] [Trace] Try service: 'CheckMkService'
2025-07-04 10:25:39.950 [srv 3184] [Trace] Try registry 'CheckMkService'
2025-07-04 10:25:39.950 [srv 3184] [Trace] Service is found 'C:\Program Files (x86)\checkmk\service\check_mk_agent.exe'
2025-07-04 10:25:39.951 [srv 3184] Set root 'C:\Program Files (x86)\checkmk\service' from registry 'CheckMkService'
2025-07-04 10:25:39.951 [srv 3184] [Trace] Try registry 'CheckMkService'
2025-07-04 10:25:39.951 [srv 3184] Protect file from User write 'C:\Program Files (x86)\checkmk\service\check_mk_agent.exe'
2025-07-04 10:25:39.952 [srv 3184] Protect path from User access 'C:\Program Files (x86)\checkmk\service'
2025-07-04 10:25:39.952 [srv 3184] Protect path from User access 'C:\ProgramData\checkmk'
2025-07-04 10:25:39.952 [srv 3184] Protect path from User access 'C:\ProgramData\checkmk\agent'
2025-07-04 10:25:39.962 [srv 3184] [Trace] Using root = 'C:\Program Files (x86)\checkmk\service' and data = 'C:\ProgramData\checkmk\agent' folders 
2025-07-04 10:25:39.964 [srv 3184] COM Initialized
2025-07-04 10:25:39.965 [srv 3184] COM initialized
2025-07-04 10:25:39.965 [srv 3184] Found root config on path C:\Program Files (x86)\checkmk\service\check_mk.yml
2025-07-04 10:25:39.971 [srv 3184] [Trace] Enabled Debug
2025-07-04 10:25:39.971 [srv 3184] Loaded start config 'C:\Program Files (x86)\checkmk\service\check_mk.yml','C:\ProgramData\checkmk\agent\bakery','C:\ProgramData\checkmk\agent\check_mk.user.yml'
2025-07-04 10:25:39.972 [srv 3184] service to run
2025-07-04 10:25:39.974 [srv 3184] Service Main
2025-07-04 10:25:39.974 [srv 3184] Service handlers registered
2025-07-04 10:25:39.975 [srv 3184] Setting service state 2 result 0
2025-07-04 10:25:39.975 [srv 3184] [Trace] Installing cap file 'C:\Program Files (x86)\checkmk\service\install\plugins.cap'
2025-07-04 10:25:39.975 [srv 3184] Target File 'C:\ProgramData\checkmk\agent\install\plugins.cap' is absent, reinstall is mandatory
2025-07-04 10:25:39.975 [srv 3184] Reinstalling 'C:\ProgramData\checkmk\agent\install\plugins.cap' with 'C:\Program Files (x86)\checkmk\service\install\plugins.cap'
2025-07-04 10:25:39.976 [srv 3184] [Trace] File 'C:\ProgramData\checkmk\agent\install\plugins.cap' is absent, skipping uninstall
2025-07-04 10:25:39.976 [srv 3184] [Trace] End of CAP-file. OK!
2025-07-04 10:25:39.976 [srv 3184] [Trace] File CAP end!
2025-07-04 10:25:39.976 [srv 3184] [Trace] File 'C:\Program Files (x86)\checkmk\service\install\plugins.cap' installed
2025-07-04 10:25:39.977 [srv 3184] [Trace] Installing yml file 'C:\Program Files (x86)\checkmk\service\install\check_mk.install.yml'
2025-07-04 10:25:39.977 [srv 3184] Target File 'C:\ProgramData\checkmk\agent\install\check_mk.install.yml' is absent, reinstall is mandatory
2025-07-04 10:25:39.978 [srv 3184] Reinstalling 'C:\ProgramData\checkmk\agent\install\check_mk.install.yml' with 'C:\Program Files (x86)\checkmk\service\install\check_mk.install.yml'
2025-07-04 10:25:39.978 [srv 3184] This Option/YML installation form MSI is ENABLED
2025-07-04 10:25:39.978 [srv 3184] Remove 'C:\ProgramData\checkmk\agent\install\check_mk.install.yml' [OK]
2025-07-04 10:25:39.978 [srv 3184] Supplied yaml 'C:\Program Files (x86)\checkmk\service\install\check_mk.install.yml' will not be installed
2025-07-04 10:25:39.979 [srv 3184] [Trace] Copy file 'C:\Program Files (x86)\checkmk\service\install\checkmk.dat' to 'C:\ProgramData\checkmk\agent\install\checkmk.dat'
2025-07-04 10:25:39.979 [srv 3184] Target File 'C:\ProgramData\checkmk\agent\install\checkmk.dat' is absent, reinstall is mandatory
2025-07-04 10:25:39.979 [srv 3184] Reinstalling 'C:\ProgramData\checkmk\agent\install\checkmk.dat' with 'C:\Program Files (x86)\checkmk\service\install\checkmk.dat'
2025-07-04 10:25:39.980 [srv 3184] 	Success
2025-07-04 10:25:39.980 [srv 3184] Installing user yml file
2025-07-04 10:25:39.981 [srv 3184] [Trace] Copy file 'C:\Program Files (x86)\checkmk\service\install\check_mk.user.yml' to 'C:\ProgramData\checkmk\agent\check_mk.user.yml'
2025-07-04 10:25:39.981 [srv 3184] Target File 'C:\ProgramData\checkmk\agent\check_mk.user.yml' is absent, reinstall is mandatory
2025-07-04 10:25:39.981 [srv 3184] Reinstalling 'C:\ProgramData\checkmk\agent\check_mk.user.yml' with 'C:\Program Files (x86)\checkmk\service\install\check_mk.user.yml'
2025-07-04 10:25:39.982 [srv 3184] 	Success
2025-07-04 10:25:39.982 [srv 3184] Target File 'C:\ProgramData\checkmk\agent\check_mk.user.example.yml' is absent, reinstall is mandatory
2025-07-04 10:25:39.983 [srv 3184] User Example must be updated
2025-07-04 10:25:39.984 [srv 3184] User Example 'C:\ProgramData\checkmk\agent\check_mk.user.example.yml' have been updated successfully from 'C:\Program Files (x86)\checkmk\service\install\check_mk.user.yml'
2025-07-04 10:25:39.984 [srv 3184] Migration is disabled in registry by installer
2025-07-04 10:25:39.984 [srv 3184] [Trace] trying path C:\Program Files (x86)\checkmk\service
2025-07-04 10:25:39.985 [srv 3184] Found root config on path C:\Program Files (x86)\checkmk\service\check_mk.yml
2025-07-04 10:25:39.985 [srv 3184] [Trace] Loading 'C:\Program Files (x86)\checkmk\service\check_mk.yml'
2025-07-04 10:25:39.987 [srv 3184] [Trace] Loading 'C:\ProgramData\checkmk\agent\bakery\check_mk.bakery.yml'
2025-07-04 10:25:39.988 [srv 3184] [Trace] C:\ProgramData\checkmk\agent\bakery\check_mk.bakery.yml is absent, return
2025-07-04 10:25:39.988 [srv 3184] [Trace] Loading 'C:\ProgramData\checkmk\agent\check_mk.user.yml'
2025-07-04 10:25:39.994 [srv 3184] [Trace] Target 'folders' is empty, overriding with source
2025-07-04 10:25:39.995 [srv 3184] Loaded Config Files by Agent [2.4.0p5,64bit,release,Jun 23 2025,21:11:08] @ 'Win8.1-64 server'
    root:   'C:\Program Files (x86)\checkmk\service\check_mk.yml' size=13186 [OK]
    bakery: 'C:\ProgramData\checkmk\agent\bakery\check_mk.bakery.yml' size=0 [OK]
    user:   'C:\ProgramData\checkmk\agent\check_mk.user.yml' size=17802 [OK]
2025-07-04 10:25:39.996 [srv 3184] [Trace] Enabled Debug
2025-07-04 10:25:39.996 [srv 3184] Loaded start config 'C:\Program Files (x86)\checkmk\service\check_mk.yml','C:\ProgramData\checkmk\agent\bakery','C:\ProgramData\checkmk\agent\check_mk.user.yml'
2025-07-04 10:25:39.997 [srv 3184] [Trace] Successful start of thread
2025-07-04 10:25:39.997 [srv 3184] Setting service state 4 result 0
2025-07-04 10:25:39.998 [srv 3184] The network is available
2025-07-04 10:25:39.998 [srv 3184] starting controller
2025-07-04 10:25:39.999 [srv 3184] Processing dir 'C:\ProgramData\checkmk\agent\bin'
2025-07-04 10:25:40.020 [srv 3184] killed 0 processes in 'C:\ProgramData\checkmk\agent\bin'
2025-07-04 10:25:40.055 [srv 3184] Agent controller 'C:\ProgramData\checkmk\agent\bin\cmk-agent-ctl.exe -vv daemon --agent-channel ms/Global\WinAgent_0' started pid [2436]
2025-07-04 10:25:40.095 [ctl:2436] [cmk_agent_ctl][INFO] starting
2025-07-04 10:25:40.126 [ctl:2436] [cmk_agent_ctl][INFO] Loaded config from '"C:\\ProgramData\\checkmk\\agent\\cmk-agent-ctl.toml"', connection registry from '"C:\\ProgramData\\checkmk\\agent\\registered_connections.json"'
2025-07-04 10:25:40.157 [ctl:2436] [cmk_agent_ctl::modes::daemon][INFO] Could not load pre-configured connections from "C:\\ProgramData\\checkmk\\agent\\pre_configured_connections.json": Das System kann die angegebene Datei nicht finden. (os error 2)
2025-07-04 10:25:40.189 [ctl:2436] [cmk_agent_ctl::misc][DEBUG] Sleeping 15s to avoid DDOSing of sites
2025-07-04 10:25:40.220 [ctl:2436] [cmk_agent_ctl::misc][DEBUG] Sleeping 43s to avoid DDOSing of sites
2025-07-04 10:25:41.064 [srv 3184] Controller has started: firewall to controller
2025-07-04 10:25:41.064 [srv 3184] Firewall mode is set to configure, adding rule...
2025-07-04 10:25:41.065 [srv 3184] Removing all 'Checkmk Agent' app: 'C:\ProgramData\checkmk\agent\bin\cmk-agent-ctl.exe'
2025-07-04 10:25:41.118 [srv 3184] Removed 1 old rules.
2025-07-04 10:25:41.123 [srv 3184] Firewall rule 'Checkmk Agent' had been added successfully for ports [6556]
2025-07-04 10:25:41.125 [srv 3184] File 'C:\ProgramData\cmk_agent_uninstall.txt'  is absent, assuming fresh install, legacy pull mode ON
2025-07-04 10:25:41.125 [srv 3184] Reading module config normal
2025-07-04 10:25:41.126 [srv 3184] Processed [1] module(s)
2025-07-04 10:25:41.126 [srv 3184] Finding modules
2025-07-04 10:25:41.126 [srv 3184] Module 'C:\Program Files (x86)\checkmk\service\install\python-3.cab' is added to the list
2025-07-04 10:25:41.126 [srv 3184] Installing modules
2025-07-04 10:25:41.127 [srv 3184] Install module python-3
2025-07-04 10:25:41.128 [srv 3184] 'C:\ProgramData\checkmk\agent\install\modules\python-3.cab' is absent, no need to uninstall
2025-07-04 10:25:41.128 [srv 3184] Installation of the module 'python-3' is not required, module file 'C:\Program Files (x86)\checkmk\service\install\python-3.cab'is absent or too short. Backup will be uninstalled
2025-07-04 10:25:41.128 [srv 3184] Module 'python-3' has no package installed, this is normal
2025-07-04 10:25:41.128 [srv 3184] [Warn ] Module 'python-3' has no package in backup dir 'C:\ProgramData\checkmk\agent\install\modules'
2025-07-04 10:25:41.130 [srv 3184] Temp folder: C:\Windows\TEMP\cmk_service
2025-07-04 10:25:41.130 [srv 3184] Pre Start actions
2025-07-04 10:25:41.131 [srv 3184] Agent extension 'robot_mk' to be processed
2025-07-04 10:25:41.131 [srv 3184] [Warn ] OHM file 'C:\ProgramData\checkmk\agent\bin\OpenHardwareMonitorCLI.exe' is not found
2025-07-04 10:25:41.131 [srv 3184] 'C:\ProgramData\checkmk\agent/bin/robotmk_ext.exe' not found, skipping
2025-07-04 10:25:41.132 [srv 3184] Allowed Extensions: [checkmk.py,py,exe,bat,vbs,cmd,ps1]
2025-07-04 10:25:41.132 [srv 3184] [Trace] Left [36] files to execute
2025-07-04 10:25:41.135 [srv 3184] [Trace] Left [0] files to execute in 'plugins'
2025-07-04 10:25:41.136 [srv 3184] Allowed Extensions: [checkmk.py,py,exe,bat,vbs,cmd,ps1]
2025-07-04 10:25:41.136 [srv 3184] [Trace] Left [36] files to execute
2025-07-04 10:25:41.139 [srv 3184] [Trace] Left [0] files to execute in 'plugins'
2025-07-04 10:25:41.139 [srv 3184] Allowed Extensions: [exe,bat,vbs,cmd,ps1]
2025-07-04 10:25:41.139 [srv 3184] [Trace] Left [0] files to execute
2025-07-04 10:25:41.139 [srv 3184] [Trace] Left [0] files to execute in 'local'
2025-07-04 10:25:41.140 [srv 3184] Pre Start actions ended
2025-07-04 10:25:41.642 [srv 3184] Waiting for async threads [0]
2025-07-04 10:25:41.642 [srv 3184] Left async threads [0] after waiting 0ms
2025-07-04 10:25:41.643 [srv 3184] Starting io with 0 2436
2025-07-04 10:25:41.643 [srv 3184] main Wait Loop
2025-07-04 10:25:41.644 [srv 3184] Applying config auto restart_on_crash:true error_mode: log
2025-07-04 10:25:41.644 [srv 3184] cma::world::ExternalPort::mailslotThreadProc:  started

Does anyone know why this is happening?

Is the proxy registration maybe the problem? (Although If I remember correctly some time ago I could register the host normally and the same phenomenon happend…)

Or maybe it’s a problem with windows and its user permissions or something like that?

I upgraded the agent to Version 2.4.0p7 and did the proxy-register again on another host. (This time I piped the output into a file and copied the whole file instead of just copy pasting the contents, but this shouldn’t make a difference I guess)

And now it seems to work.
After a restart all the config and the plugin are still there (and I also the older logfiles).

Maybe using the newest agent version fixed this.