[GH-ISSUE #1250] Agent fails to update because previous update is still running #2717

Closed
opened 2026-03-14 05:13:13 +03:00 by kerem · 22 comments
Owner

Originally created by @NiceGuyIT on GitHub (Aug 21, 2022).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/1250

Server Info (please complete the following information):

  • OS: Ubuntu 20.04.4 LTS
  • Browser: Firefox 103.0.2 (64-bit)
  • RMM Version (as shown in top left of web UI): v0.14.5

Installation Method:

  • Standard
  • Docker

Agent Info (please complete the following information):

  • Agent version (as shown in the 'Summary' tab of the agent from web UI): Agent v2.0.3
  • Agent OS: Windows 10 Pro, 64 bit v21H1 (build 19043.1889)

Describe the bug
One agent is failing to update to v2.2.1. After logging into the computer, I discovered an existing update is pending. The inno logs show the upgrade failed to delete a file, retried, and ultimately prompted with a "Message box (Abort/Retry/Ignore)". The agent upgrade code starts the command but never checks if the command completed. Yes, I know it can't check if the current command spawned finished because part of the upgrade process is to restart the service. However, it can check if a previous upgrade is hung or still running. The agent.log shows the agent keeps trying to update but fails because the tacticalagent-v2.2.1-windows-amd64.exe is in use by another process. That other process is the previous upgrade that is waiting for a prompt.

To Reproduce
Steps to reproduce the behavior:

  1. I don't know how to reproducible this problem.

Expected behavior
I expect the agent to check if a previous upgrade is hung and handle the situation.

Screenshots
Here is a screenshot of the existing setup from Process Explorer.
image

Here is the properties of the upgrade process started on 2022-08-19 10:35:05 PM.
image

Additional context
The inno setup log is below.

C:\Program Files\TacticalAgent\agent.log:

time="2022-08-21T10:35:09-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1"
time="2022-08-21T10:35:09-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-08-21T10:35:09-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process."
time="2022-08-21T10:35:15-04:00" level=info msg="Agent service started"
time="2022-08-21T11:35:13-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1"
time="2022-08-21T11:35:13-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-08-21T11:35:14-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process."
time="2022-08-21T11:35:19-04:00" level=info msg="Agent service started"
time="2022-08-21T12:25:23-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1"
time="2022-08-21T12:25:23-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-08-21T12:25:23-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process."
time="2022-08-21T12:25:29-04:00" level=info msg="Agent service started"
time="2022-08-21T12:35:12-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1"
time="2022-08-21T12:35:12-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-08-21T12:35:12-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process."
time="2022-08-21T12:35:18-04:00" level=info msg="Agent service started"

C:\Windows\Temp\tacticalrmm3774362645\tacticalrmm.txt:

2022-08-19 22:35:07.147   Log opened. (Time zone: UTC-04:00)
2022-08-19 22:35:07.147   Setup version: Inno Setup version 6.2.1
2022-08-19 22:35:07.147   Original Setup EXE: C:\Program Files\TacticalAgent\tacticalagent-v2.2.1-windows-amd64.exe
2022-08-19 22:35:07.147   Setup command line: /SL5="$1C0046,3433926,825344,C:\Program Files\TacticalAgent\tacticalagent-v2.2.1-windows-amd64.exe" /VERYSILENT /LOG=C:\WINDOWS\TEMP\tacticalrmm3774362645\tacticalrmm.txt
2022-08-19 22:35:07.147   Windows version: 10.0.19043  (NT platform: Yes)
2022-08-19 22:35:07.147   64-bit Windows: Yes
2022-08-19 22:35:07.147   Processor architecture: x64
2022-08-19 22:35:07.147   User privileges: Administrative
2022-08-19 22:35:07.163   Administrative install mode: Yes
2022-08-19 22:35:07.163   Install mode root key: HKEY_LOCAL_MACHINE
2022-08-19 22:35:07.163   64-bit install mode: No
2022-08-19 22:35:07.178   Created temporary directory: C:\WINDOWS\TEMP\is-MUSDO.tmp
2022-08-19 22:35:08.556   Stop tacticalrpc: 2
2022-08-19 22:35:08.771   Stop tacticalagent: 2
2022-08-19 22:35:10.059   Stop tacticalrmm: 2
2022-08-19 22:35:10.422   taskkill: 128
2022-08-19 22:35:10.571   delete tacticalagent: 1060
2022-08-19 22:35:10.714   delete tacticalrpc: 1060
2022-08-19 22:35:10.927   Starting the installation process.
2022-08-19 22:35:10.927   Directory for uninstall files: C:\Program Files\TacticalAgent
2022-08-19 22:35:10.927   Will append to existing uninstall log: C:\Program Files\TacticalAgent\unins000.dat
2022-08-19 22:35:10.958   -- File entry --
2022-08-19 22:35:10.958   Dest filename: C:\Program Files\TacticalAgent\unins000.exe
2022-08-19 22:35:10.974   Time stamp of our file: 2022-08-19 22:35:06.475
2022-08-19 22:35:10.974   Dest file exists.
2022-08-19 22:35:10.974   Time stamp of existing file: 2022-04-28 06:35:08.812
2022-08-19 22:35:10.974   Version of our file: 51.1052.0.0
2022-08-19 22:35:11.177   Version of existing file: 51.1052.0.0
2022-08-19 22:35:11.177   Installing the file.
2022-08-19 22:35:11.371   Leaving temporary file in place for now.
2022-08-19 22:35:11.371   -- File entry --
2022-08-19 22:35:11.371   Dest filename: C:\Program Files\TacticalAgent\tacticalrmm.exe
2022-08-19 22:35:11.371   Time stamp of our file: 2022-08-01 15:48:00.000
2022-08-19 22:35:11.371   Dest file exists.
2022-08-19 22:35:11.371   Time stamp of existing file: 2022-04-22 11:41:58.000
2022-08-19 22:35:11.371   Installing the file.
2022-08-19 22:35:12.148   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-08-19 22:35:13.162   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-08-19 22:35:14.166   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-08-19 22:35:15.182   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-08-19 22:35:16.197   Message box (Abort/Retry/Ignore):
                          C:\Program Files\TacticalAgent\tacticalrmm.exe
                          
                          An error occurred while trying to replace the existing file:
                          DeleteFile failed; code 5.
                          Access is denied.
Originally created by @NiceGuyIT on GitHub (Aug 21, 2022). Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/1250 **Server Info (please complete the following information):** - OS: Ubuntu 20.04.4 LTS - Browser: Firefox 103.0.2 (64-bit) - RMM Version (as shown in top left of web UI): v0.14.5 **Installation Method:** - [x] Standard - [ ] Docker **Agent Info (please complete the following information):** - Agent version (as shown in the 'Summary' tab of the agent from web UI): Agent v2.0.3 - Agent OS: Windows 10 Pro, 64 bit v21H1 (build 19043.1889) **Describe the bug** One agent is failing to update to v2.2.1. After logging into the computer, I discovered an existing update is pending. The inno logs show the upgrade failed to delete a file, retried, and ultimately prompted with a "Message box (Abort/Retry/Ignore)". The [agent upgrade code](https://github.com/amidaware/rmmagent/blob/develop/agent/agent_windows.go#L618) starts the command but never checks if the command completed. Yes, I know it can't check if the *current* command spawned finished because part of the upgrade process is to restart the service. However, it **can** check if a previous upgrade is hung or still running. The `agent.log` shows the agent keeps trying to update but fails because the `tacticalagent-v2.2.1-windows-amd64.exe` is in use by another process. That other process is the previous upgrade that is waiting for a prompt. **To Reproduce** Steps to reproduce the behavior: 1. I don't know how to reproducible this problem. **Expected behavior** I expect the agent to check if a previous upgrade is hung and handle the situation. **Screenshots** Here is a screenshot of the existing setup from Process Explorer. ![image](https://user-images.githubusercontent.com/7763429/185802192-fef95468-c24e-4bc7-aeab-5e1cd59ea8f1.png) Here is the properties of the upgrade process started on 2022-08-19 10:35:05 PM. ![image](https://user-images.githubusercontent.com/7763429/185802244-117ee890-33d7-4fb4-8b08-f78e22cdd84d.png) **Additional context** The inno setup log is below. **C:\Program Files\TacticalAgent\agent.log**: ```text time="2022-08-21T10:35:09-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1" time="2022-08-21T10:35:09-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-08-21T10:35:09-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process." time="2022-08-21T10:35:15-04:00" level=info msg="Agent service started" time="2022-08-21T11:35:13-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1" time="2022-08-21T11:35:13-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-08-21T11:35:14-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process." time="2022-08-21T11:35:19-04:00" level=info msg="Agent service started" time="2022-08-21T12:25:23-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1" time="2022-08-21T12:25:23-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-08-21T12:25:23-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process." time="2022-08-21T12:25:29-04:00" level=info msg="Agent service started" time="2022-08-21T12:35:12-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1" time="2022-08-21T12:35:12-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-08-21T12:35:12-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process." time="2022-08-21T12:35:18-04:00" level=info msg="Agent service started" ``` **C:\Windows\Temp\tacticalrmm3774362645\tacticalrmm.txt**: ```text 2022-08-19 22:35:07.147 Log opened. (Time zone: UTC-04:00) 2022-08-19 22:35:07.147 Setup version: Inno Setup version 6.2.1 2022-08-19 22:35:07.147 Original Setup EXE: C:\Program Files\TacticalAgent\tacticalagent-v2.2.1-windows-amd64.exe 2022-08-19 22:35:07.147 Setup command line: /SL5="$1C0046,3433926,825344,C:\Program Files\TacticalAgent\tacticalagent-v2.2.1-windows-amd64.exe" /VERYSILENT /LOG=C:\WINDOWS\TEMP\tacticalrmm3774362645\tacticalrmm.txt 2022-08-19 22:35:07.147 Windows version: 10.0.19043 (NT platform: Yes) 2022-08-19 22:35:07.147 64-bit Windows: Yes 2022-08-19 22:35:07.147 Processor architecture: x64 2022-08-19 22:35:07.147 User privileges: Administrative 2022-08-19 22:35:07.163 Administrative install mode: Yes 2022-08-19 22:35:07.163 Install mode root key: HKEY_LOCAL_MACHINE 2022-08-19 22:35:07.163 64-bit install mode: No 2022-08-19 22:35:07.178 Created temporary directory: C:\WINDOWS\TEMP\is-MUSDO.tmp 2022-08-19 22:35:08.556 Stop tacticalrpc: 2 2022-08-19 22:35:08.771 Stop tacticalagent: 2 2022-08-19 22:35:10.059 Stop tacticalrmm: 2 2022-08-19 22:35:10.422 taskkill: 128 2022-08-19 22:35:10.571 delete tacticalagent: 1060 2022-08-19 22:35:10.714 delete tacticalrpc: 1060 2022-08-19 22:35:10.927 Starting the installation process. 2022-08-19 22:35:10.927 Directory for uninstall files: C:\Program Files\TacticalAgent 2022-08-19 22:35:10.927 Will append to existing uninstall log: C:\Program Files\TacticalAgent\unins000.dat 2022-08-19 22:35:10.958 -- File entry -- 2022-08-19 22:35:10.958 Dest filename: C:\Program Files\TacticalAgent\unins000.exe 2022-08-19 22:35:10.974 Time stamp of our file: 2022-08-19 22:35:06.475 2022-08-19 22:35:10.974 Dest file exists. 2022-08-19 22:35:10.974 Time stamp of existing file: 2022-04-28 06:35:08.812 2022-08-19 22:35:10.974 Version of our file: 51.1052.0.0 2022-08-19 22:35:11.177 Version of existing file: 51.1052.0.0 2022-08-19 22:35:11.177 Installing the file. 2022-08-19 22:35:11.371 Leaving temporary file in place for now. 2022-08-19 22:35:11.371 -- File entry -- 2022-08-19 22:35:11.371 Dest filename: C:\Program Files\TacticalAgent\tacticalrmm.exe 2022-08-19 22:35:11.371 Time stamp of our file: 2022-08-01 15:48:00.000 2022-08-19 22:35:11.371 Dest file exists. 2022-08-19 22:35:11.371 Time stamp of existing file: 2022-04-22 11:41:58.000 2022-08-19 22:35:11.371 Installing the file. 2022-08-19 22:35:12.148 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-08-19 22:35:13.162 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-08-19 22:35:14.166 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-08-19 22:35:15.182 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-08-19 22:35:16.197 Message box (Abort/Retry/Ignore): C:\Program Files\TacticalAgent\tacticalrmm.exe An error occurred while trying to replace the existing file: DeleteFile failed; code 5. Access is denied. ```
kerem closed this issue 2026-03-14 05:13:18 +03:00
Author
Owner

@NiceGuyIT commented on GitHub (Aug 21, 2022):

Restarting the service does not kill the hung install process. I had to kill the install process before the installation was tried again, and it hung with the same error.

All computers are restarted weekly at 10:00 PM local time. The hung install process was from 10:35:05 PM right after the restart. While restarting the computer and then forcing the update worked today, the automated update from Friday night did not. Also, I believe this agent was not updating before Friday. I just haven't had time to dive into why it wasn't updating.

At the very least, the rmmagent should detect hung upgrades and handle the situation to allow the next update to possibly work.

<!-- gh-comment-id:1221587119 --> @NiceGuyIT commented on GitHub (Aug 21, 2022): Restarting the service does not kill the hung install process. I had to kill the install process before the installation was tried again, and it hung with the same error. All computers are restarted weekly at 10:00 PM local time. The hung install process was from 10:35:05 PM right after the restart. While restarting the computer and then forcing the update worked today, the automated update from Friday night did not. Also, I believe this agent was not updating before Friday. I just haven't had time to dive into why it wasn't updating. At the very least, the rmmagent should detect hung upgrades and handle the situation to allow the next update to possibly work.
Author
Owner

@NiceGuyIT commented on GitHub (Aug 21, 2022):

The agent.log shows the upgrade failed ever since I upgraded the server on 2022-08-09.

time="2022-08-09T08:35:03-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1"
time="2022-08-09T08:35:03-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-08-09T08:35:11-04:00" level=info msg="Agent service started"
time="2022-08-09T09:35:13-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1"
time="2022-08-09T09:35:13-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-08-09T09:35:14-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process."
time="2022-08-09T09:35:19-04:00" level=info msg="Agent service started"
time="2022-08-09T10:35:08-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1"
time="2022-08-09T10:35:08-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-08-09T10:35:08-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process."
<!-- gh-comment-id:1221591135 --> @NiceGuyIT commented on GitHub (Aug 21, 2022): The `agent.log` shows the upgrade failed ever since I upgraded the server on 2022-08-09. ```text time="2022-08-09T08:35:03-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1" time="2022-08-09T08:35:03-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-08-09T08:35:11-04:00" level=info msg="Agent service started" time="2022-08-09T09:35:13-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1" time="2022-08-09T09:35:13-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-08-09T09:35:14-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process." time="2022-08-09T09:35:19-04:00" level=info msg="Agent service started" time="2022-08-09T10:35:08-04:00" level=info msg="Agent updating from 2.0.3 to 2.2.1" time="2022-08-09T10:35:08-04:00" level=info msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.2.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-08-09T10:35:08-04:00" level=error msg="open C:\\Program Files\\TacticalAgent\\tacticalagent-v2.2.1-windows-amd64.exe: The process cannot access the file because it is being used by another process." ```
Author
Owner

@wh1te909 commented on GitHub (Aug 21, 2022):

the agent already has a KillHungUpdates() function and calls it before it attempts to update. Since the agent binary naming format changed though I just recently added the pattern matching tacticalagent-v* to that function so you probably are still on the agent that doesn't have that updated function yet so it won't work until you actually update to that agent so you might need to do it manually for this one and in future it will work.

<!-- gh-comment-id:1221602057 --> @wh1te909 commented on GitHub (Aug 21, 2022): the agent already has a [KillHungUpdates()](https://github.com/amidaware/rmmagent/blob/89d7ec8242811b3cbe0f5f425b597c1ef8458175/agent/process.go#L56) function and calls it before it attempts to update. Since the agent binary naming format changed though I just recently added the pattern matching `tacticalagent-v*` to that function so you probably are still on the agent that doesn't have that updated function yet so it won't work until you actually update to that agent so you might need to do it manually for this one and in future it will work.
Author
Owner

@NiceGuyIT commented on GitHub (Aug 21, 2022):

Looks like that was first available in v2.1.0. Closing this as it should no longer be an issue. Thanks!

<!-- gh-comment-id:1221609985 --> @NiceGuyIT commented on GitHub (Aug 21, 2022): Looks like that was first available in [v2.1.0](https://github.com/amidaware/rmmagent/releases/tag/v2.1.0). Closing this as it should no longer be an issue. Thanks!
Author
Owner

@NiceGuyIT commented on GitHub (Aug 25, 2022):

While troubleshooting issue #1265, I tried upgrading from version v2.1.1 and it failed several times. If I waited until the installer started and then stopped the tacticalrmm service, the upgrade was successful. I suspect this is a race condition and killing the previous update makes it try again which eventually succeeds.

<!-- gh-comment-id:1227502088 --> @NiceGuyIT commented on GitHub (Aug 25, 2022): While troubleshooting issue #1265, I tried upgrading from version v2.1.1 and it failed several times. If I waited until the installer started and then stopped the tacticalrmm service, the upgrade was successful. I suspect this is a race condition and killing the previous update makes it try again which eventually succeeds.
Author
Owner

@NiceGuyIT commented on GitHub (Sep 26, 2022):

This is happening again after upgrading. Linux agents updated without a problem. All but 2 Windows Servers updated without a problem. 12 Windows workstations failed and 3 succeeded. Of the 3 that succeeded, 2 are VMs and 1 is a slow laptop. I believe this is a race condition. How do I troubleshoot?

Previous version:

  • TRMM_VERSION = "0.14.5"
  • LATEST_AGENT_VER = "2.2.1"

Current version:

  • TRMM_VERSION = "0.15.0"
  • LATEST_AGENT_VER = "2.4.0"

Based on the release dates, I skipped two tacticalagent versions.

  • tacticalagent-v2.2.1 == TacticalRMM Release v0.14.5 <-- Previous version
  • tacticalagent-v2.3.0 == TacticalRMM Release v0.14.6 <-- Skipped
  • tacticalagent-v2.3.1 == TacticalRMM Release v0.14.8 <-- Skipped
  • tacticalagent-v2.4.0 == TacticalRMM Release v0.15.0 <-- Current version
<!-- gh-comment-id:1258318101 --> @NiceGuyIT commented on GitHub (Sep 26, 2022): This is happening again after upgrading. Linux agents updated without a problem. All but 2 Windows Servers updated without a problem. 12 Windows workstations failed and 3 succeeded. Of the 3 that succeeded, 2 are VMs and 1 is a slow laptop. I believe this is a race condition. How do I troubleshoot? Previous version: - TRMM_VERSION = "0.14.5" - LATEST_AGENT_VER = "2.2.1" Current version: - TRMM_VERSION = "0.15.0" - LATEST_AGENT_VER = "2.4.0" Based on the release dates, I skipped two tacticalagent versions. - tacticalagent-v2.2.1 == TacticalRMM Release v0.14.5 <-- **Previous version** - tacticalagent-v2.3.0 == TacticalRMM Release v0.14.6 <-- **Skipped** - tacticalagent-v2.3.1 == TacticalRMM Release v0.14.8 <-- **Skipped** - tacticalagent-v2.4.0 == TacticalRMM Release v0.15.0 <-- **Current version**
Author
Owner

@NiceGuyIT commented on GitHub (Sep 26, 2022):

Here's the setup log from the latest run.

C:\Windows\Temp\tacticalrmm366239534\tacticalrmm.txt

2022-09-26 12:35:05.167   Log opened. (Time zone: UTC-04:00)
2022-09-26 12:35:05.167   Setup version: Inno Setup version 6.2.1
2022-09-26 12:35:05.167   Original Setup EXE: C:\Program Files\TacticalAgent\tacticalagent-v2.4.0-windows-amd64.exe
2022-09-26 12:35:05.167   Setup command line: /SL5="$2700B8,3441125,825344,C:\Program Files\TacticalAgent\tacticalagent-v2.4.0-windows-amd64.exe" /VERYSILENT /LOG=C:\WINDOWS\TEMP\tacticalrmm366239534\tacticalrmm.txt
2022-09-26 12:35:05.167   Windows version: 10.0.19044  (NT platform: Yes)
2022-09-26 12:35:05.167   64-bit Windows: Yes
2022-09-26 12:35:05.167   Processor architecture: x64
2022-09-26 12:35:05.167   User privileges: Administrative
2022-09-26 12:35:05.169   Administrative install mode: Yes
2022-09-26 12:35:05.169   Install mode root key: HKEY_LOCAL_MACHINE
2022-09-26 12:35:05.169   64-bit install mode: No
2022-09-26 12:35:05.178   Created temporary directory: C:\WINDOWS\TEMP\is-K7G4F.tmp
2022-09-26 12:35:06.386   Stop tacticalrpc: 2
2022-09-26 12:35:06.512   Stop tacticalagent: 2
2022-09-26 12:35:07.704   Stop tacticalrmm: 2
2022-09-26 12:35:07.915   taskkill: 128
2022-09-26 12:35:07.995   delete tacticalagent: 1060
2022-09-26 12:35:08.072   delete tacticalrpc: 1060
2022-09-26 12:35:08.112   Starting the installation process.
2022-09-26 12:35:08.115   Directory for uninstall files: C:\Program Files\TacticalAgent
2022-09-26 12:35:08.115   Will append to existing uninstall log: C:\Program Files\TacticalAgent\unins000.dat
2022-09-26 12:35:08.117   -- File entry --
2022-09-26 12:35:08.117   Dest filename: C:\Program Files\TacticalAgent\unins000.exe
2022-09-26 12:35:08.122   Time stamp of our file: 2022-09-26 12:35:04.603
2022-09-26 12:35:08.122   Dest file exists.
2022-09-26 12:35:08.122   Time stamp of existing file: 2022-08-09 08:35:12.944
2022-09-26 12:35:08.122   Version of our file: 51.1052.0.0
2022-09-26 12:35:08.123   Version of existing file: 51.1052.0.0
2022-09-26 12:35:08.123   Installing the file.
2022-09-26 12:35:08.217   Leaving temporary file in place for now.
2022-09-26 12:35:08.217   -- File entry --
2022-09-26 12:35:08.217   Dest filename: C:\Program Files\TacticalAgent\tacticalrmm.exe
2022-09-26 12:35:08.217   Time stamp of our file: 2022-09-23 19:19:32.000
2022-09-26 12:35:08.217   Dest file exists.
2022-09-26 12:35:08.218   Time stamp of existing file: 2022-08-01 15:48:00.000
2022-09-26 12:35:08.218   Installing the file.
2022-09-26 12:35:13.023   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-09-26 12:35:14.033   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-09-26 12:35:15.049   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-09-26 12:35:16.051   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-09-26 12:35:17.055   Message box (Abort/Retry/Ignore):
                          C:\Program Files\TacticalAgent\tacticalrmm.exe
                          
                          An error occurred while trying to replace the existing file:
                          DeleteFile failed; code 5.
                          Access is denied.
<!-- gh-comment-id:1258324708 --> @NiceGuyIT commented on GitHub (Sep 26, 2022): Here's the setup log from the latest run. `C:\Windows\Temp\tacticalrmm366239534\tacticalrmm.txt` ```text 2022-09-26 12:35:05.167 Log opened. (Time zone: UTC-04:00) 2022-09-26 12:35:05.167 Setup version: Inno Setup version 6.2.1 2022-09-26 12:35:05.167 Original Setup EXE: C:\Program Files\TacticalAgent\tacticalagent-v2.4.0-windows-amd64.exe 2022-09-26 12:35:05.167 Setup command line: /SL5="$2700B8,3441125,825344,C:\Program Files\TacticalAgent\tacticalagent-v2.4.0-windows-amd64.exe" /VERYSILENT /LOG=C:\WINDOWS\TEMP\tacticalrmm366239534\tacticalrmm.txt 2022-09-26 12:35:05.167 Windows version: 10.0.19044 (NT platform: Yes) 2022-09-26 12:35:05.167 64-bit Windows: Yes 2022-09-26 12:35:05.167 Processor architecture: x64 2022-09-26 12:35:05.167 User privileges: Administrative 2022-09-26 12:35:05.169 Administrative install mode: Yes 2022-09-26 12:35:05.169 Install mode root key: HKEY_LOCAL_MACHINE 2022-09-26 12:35:05.169 64-bit install mode: No 2022-09-26 12:35:05.178 Created temporary directory: C:\WINDOWS\TEMP\is-K7G4F.tmp 2022-09-26 12:35:06.386 Stop tacticalrpc: 2 2022-09-26 12:35:06.512 Stop tacticalagent: 2 2022-09-26 12:35:07.704 Stop tacticalrmm: 2 2022-09-26 12:35:07.915 taskkill: 128 2022-09-26 12:35:07.995 delete tacticalagent: 1060 2022-09-26 12:35:08.072 delete tacticalrpc: 1060 2022-09-26 12:35:08.112 Starting the installation process. 2022-09-26 12:35:08.115 Directory for uninstall files: C:\Program Files\TacticalAgent 2022-09-26 12:35:08.115 Will append to existing uninstall log: C:\Program Files\TacticalAgent\unins000.dat 2022-09-26 12:35:08.117 -- File entry -- 2022-09-26 12:35:08.117 Dest filename: C:\Program Files\TacticalAgent\unins000.exe 2022-09-26 12:35:08.122 Time stamp of our file: 2022-09-26 12:35:04.603 2022-09-26 12:35:08.122 Dest file exists. 2022-09-26 12:35:08.122 Time stamp of existing file: 2022-08-09 08:35:12.944 2022-09-26 12:35:08.122 Version of our file: 51.1052.0.0 2022-09-26 12:35:08.123 Version of existing file: 51.1052.0.0 2022-09-26 12:35:08.123 Installing the file. 2022-09-26 12:35:08.217 Leaving temporary file in place for now. 2022-09-26 12:35:08.217 -- File entry -- 2022-09-26 12:35:08.217 Dest filename: C:\Program Files\TacticalAgent\tacticalrmm.exe 2022-09-26 12:35:08.217 Time stamp of our file: 2022-09-23 19:19:32.000 2022-09-26 12:35:08.217 Dest file exists. 2022-09-26 12:35:08.218 Time stamp of existing file: 2022-08-01 15:48:00.000 2022-09-26 12:35:08.218 Installing the file. 2022-09-26 12:35:13.023 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-09-26 12:35:14.033 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-09-26 12:35:15.049 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-09-26 12:35:16.051 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-09-26 12:35:17.055 Message box (Abort/Retry/Ignore): C:\Program Files\TacticalAgent\tacticalrmm.exe An error occurred while trying to replace the existing file: DeleteFile failed; code 5. Access is denied. ```
Author
Owner

@NiceGuyIT commented on GitHub (Sep 26, 2022):

I enabled agent debugging using the script which caused the agent to restart. The agent updated successfully. Does this require the agent to restart before working properly?

time="2022-09-26T11:35:11-04:00" level=info msg="Agent updating from 2.2.1 to 2.4.0"
time="2022-09-26T11:35:18-04:00" level=info msg="Agent service started"
time="2022-09-26T12:35:02-04:00" level=info msg="Agent updating from 2.2.1 to 2.4.0"
time="2022-09-26T12:35:10-04:00" level=info msg="Agent service started"
time="2022-09-26T12:49:14-04:00" level=debug msg="{Hostname:PC-Accounting3 Arch: AgentID:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BaseURL:https://api.smb.services ApiURL:api.smb.services Token:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AgentPK:7 Cert: ProgramDir:C:\\Program Files\\TacticalAgent EXE:C:\\Program Files\\TacticalAgent\\tacticalrmm.exe SystemDrive:C: MeshInstaller:meshagent.exe MeshSystemEXE:C:\\Program Files\\Mesh Agent\\MeshAgent.exe MeshSVC:mesh agent PyBin:C:\\Program Files\\TacticalAgent\\py38-x64\\python.exe Headers:map[Authorization:Token AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Content-Type:application/json] Logger:0xc000220080 Version:2.2.1 Debug:true rClient:0xc000300000 Proxy: LogTo: LogFile:<nil> Platform:windows GoArch:amd64 ServiceConfig:0xc0002440b0 NatsServer:wss://api.smb.services:443 NatsProxyPath:natsws NatsProxyPort:443}\n"
time="2022-09-26T12:49:14-04:00" level=info msg="Agent service started"
time="2022-09-26T12:49:14-04:00" level=debug msg="CheckRunner() init sleeping for 19 seconds"
time="2022-09-26T12:49:14-04:00" level=debug msg="AgentSvc() sleeping for 19 seconds"
time="2022-09-26T12:49:33-04:00" level=debug msg="agent-hello {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2.2.1}"
time="2022-09-26T12:49:34-04:00" level=debug msg="[C:\\WINDOWS\\TEMP\\tacticalpy3225846289\\3315855747.py]"
time="2022-09-26T12:49:34-04:00" level=debug msg="agent-agentinfo {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA dAAAAAAA PC-Accounting3 Windows 10 Pro, 64 bit v21H2 (build 19044.2006) windows 16 1663984856 false amd64}"
time="2022-09-26T12:49:34-04:00" level=debug msg="Checkrunner sleeping for 120"
time="2022-09-26T12:49:34-04:00" level=debug msg="agent-disks {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA [{C: NTFS 232.3 GB 103.3 GB 128.9 GB 44}]}"
time="2022-09-26T12:49:34-04:00" level=debug msg="The resource loader failed to find MUI file."
time="2022-09-26T12:49:35-04:00" level=debug msg="PublicIP start"
time="2022-09-26T12:49:35-04:00" level=debug msg="PublicIP return:  24.172.120.194"
time="2022-09-26T12:49:35-04:00" level=debug msg="agent-publicip {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 24.172.120.194}"
time="2022-09-26T12:49:38-04:00" level=debug msg="Checking for windows updates"
time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: 01f7dc80-5870-4a79-bb59-fe9071e01405"
time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [5012170]"
time="2022-09-26T12:49:50-04:00" level=debug msg=--------------------------------
time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: 7b17ec81-a5b5-41d4-a940-e635c06f9cce"
time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [890830]"
time="2022-09-26T12:49:50-04:00" level=debug msg=--------------------------------
time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: 1cc10ba0-7791-48fe-88b2-746a50403b09"
time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [5017858]"
time="2022-09-26T12:49:50-04:00" level=debug msg=--------------------------------
time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: a329b681-ce8c-431d-99f7-052e2901adcb"
time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: false"
time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [4023057]"
time="2022-09-26T12:49:50-04:00" level=debug msg=--------------------------------
time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: a6561891-0a97-453b-828e-ed863a6e1faa"
time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true"
time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [5017308]"
time="2022-09-26T12:49:50-04:00" level=debug msg=--------------------------------
time="2022-09-26T12:50:14-04:00" level=debug msg="agent-hello {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2.2.1}"
time="2022-09-26T12:50:19-04:00" level=debug msg="killing process C:\\Program Files\\TacticalAgent\\tacticalagent-v2.4.0-windows-amd64.exe"
time="2022-09-26T12:50:19-04:00" level=debug msg="killing process C:\\Windows\\Temp\\is-J00KH.tmp\\tacticalagent-v2.4.0-windows-amd64.tmp"
time="2022-09-26T12:50:19-04:00" level=info msg="Agent updating from 2.2.1 to 2.4.0"
time="2022-09-26T12:50:19-04:00" level=debug msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.4.0&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-09-26T12:50:34-04:00" level=info msg="Agent service started"
<!-- gh-comment-id:1258346897 --> @NiceGuyIT commented on GitHub (Sep 26, 2022): I enabled agent debugging using the script which caused the agent to restart. The agent updated successfully. Does this require the agent to restart before working properly? ```text time="2022-09-26T11:35:11-04:00" level=info msg="Agent updating from 2.2.1 to 2.4.0" time="2022-09-26T11:35:18-04:00" level=info msg="Agent service started" time="2022-09-26T12:35:02-04:00" level=info msg="Agent updating from 2.2.1 to 2.4.0" time="2022-09-26T12:35:10-04:00" level=info msg="Agent service started" time="2022-09-26T12:49:14-04:00" level=debug msg="{Hostname:PC-Accounting3 Arch: AgentID:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BaseURL:https://api.smb.services ApiURL:api.smb.services Token:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AgentPK:7 Cert: ProgramDir:C:\\Program Files\\TacticalAgent EXE:C:\\Program Files\\TacticalAgent\\tacticalrmm.exe SystemDrive:C: MeshInstaller:meshagent.exe MeshSystemEXE:C:\\Program Files\\Mesh Agent\\MeshAgent.exe MeshSVC:mesh agent PyBin:C:\\Program Files\\TacticalAgent\\py38-x64\\python.exe Headers:map[Authorization:Token AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Content-Type:application/json] Logger:0xc000220080 Version:2.2.1 Debug:true rClient:0xc000300000 Proxy: LogTo: LogFile:<nil> Platform:windows GoArch:amd64 ServiceConfig:0xc0002440b0 NatsServer:wss://api.smb.services:443 NatsProxyPath:natsws NatsProxyPort:443}\n" time="2022-09-26T12:49:14-04:00" level=info msg="Agent service started" time="2022-09-26T12:49:14-04:00" level=debug msg="CheckRunner() init sleeping for 19 seconds" time="2022-09-26T12:49:14-04:00" level=debug msg="AgentSvc() sleeping for 19 seconds" time="2022-09-26T12:49:33-04:00" level=debug msg="agent-hello {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2.2.1}" time="2022-09-26T12:49:34-04:00" level=debug msg="[C:\\WINDOWS\\TEMP\\tacticalpy3225846289\\3315855747.py]" time="2022-09-26T12:49:34-04:00" level=debug msg="agent-agentinfo {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA dAAAAAAA PC-Accounting3 Windows 10 Pro, 64 bit v21H2 (build 19044.2006) windows 16 1663984856 false amd64}" time="2022-09-26T12:49:34-04:00" level=debug msg="Checkrunner sleeping for 120" time="2022-09-26T12:49:34-04:00" level=debug msg="agent-disks {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA [{C: NTFS 232.3 GB 103.3 GB 128.9 GB 44}]}" time="2022-09-26T12:49:34-04:00" level=debug msg="The resource loader failed to find MUI file." time="2022-09-26T12:49:35-04:00" level=debug msg="PublicIP start" time="2022-09-26T12:49:35-04:00" level=debug msg="PublicIP return: 24.172.120.194" time="2022-09-26T12:49:35-04:00" level=debug msg="agent-publicip {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 24.172.120.194}" time="2022-09-26T12:49:38-04:00" level=debug msg="Checking for windows updates" time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: 01f7dc80-5870-4a79-bb59-fe9071e01405" time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: true" time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true" time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [5012170]" time="2022-09-26T12:49:50-04:00" level=debug msg=-------------------------------- time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: 7b17ec81-a5b5-41d4-a940-e635c06f9cce" time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: true" time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true" time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [890830]" time="2022-09-26T12:49:50-04:00" level=debug msg=-------------------------------- time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: 1cc10ba0-7791-48fe-88b2-746a50403b09" time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: true" time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true" time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [5017858]" time="2022-09-26T12:49:50-04:00" level=debug msg=-------------------------------- time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: a329b681-ce8c-431d-99f7-052e2901adcb" time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: false" time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true" time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [4023057]" time="2022-09-26T12:49:50-04:00" level=debug msg=-------------------------------- time="2022-09-26T12:49:50-04:00" level=debug msg="GUID: a6561891-0a97-453b-828e-ed863a6e1faa" time="2022-09-26T12:49:50-04:00" level=debug msg="Downloaded: true" time="2022-09-26T12:49:50-04:00" level=debug msg="Installed: true" time="2022-09-26T12:49:50-04:00" level=debug msg="KB: [5017308]" time="2022-09-26T12:49:50-04:00" level=debug msg=-------------------------------- time="2022-09-26T12:50:14-04:00" level=debug msg="agent-hello {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2.2.1}" time="2022-09-26T12:50:19-04:00" level=debug msg="killing process C:\\Program Files\\TacticalAgent\\tacticalagent-v2.4.0-windows-amd64.exe" time="2022-09-26T12:50:19-04:00" level=debug msg="killing process C:\\Windows\\Temp\\is-J00KH.tmp\\tacticalagent-v2.4.0-windows-amd64.tmp" time="2022-09-26T12:50:19-04:00" level=info msg="Agent updating from 2.2.1 to 2.4.0" time="2022-09-26T12:50:19-04:00" level=debug msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.4.0&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-09-26T12:50:34-04:00" level=info msg="Agent service started" ```
Author
Owner

@NiceGuyIT commented on GitHub (Sep 26, 2022):

On another computer, I restarted the service and tacticalagent failed to start. Started it manually, forced the update and it still hung. Enabled debug logging using a script, forced the update and it worked. I don't know why debug logging makes it work.

<!-- gh-comment-id:1258375325 --> @NiceGuyIT commented on GitHub (Sep 26, 2022): On another computer, I restarted the service and `tacticalagent` failed to start. Started it manually, forced the update and it still hung. Enabled debug logging using a script, forced the update and it worked. I don't know why debug logging makes it work.
Author
Owner

@NiceGuyIT commented on GitHub (Sep 26, 2022):

This is pretty consistent. On a 3rd computer, agent debug was enabled, pushed the update and it worked.

On a forth computer, restated the tacticalagent service using PowerShell, forced the update and it failed. Enabled debug logging on the agent, forced the update and it worked. I have no idea why.

<!-- gh-comment-id:1258395306 --> @NiceGuyIT commented on GitHub (Sep 26, 2022): This is pretty consistent. On a 3rd computer, agent debug was enabled, pushed the update and it worked. On a forth computer, restated the tacticalagent service using PowerShell, forced the update and it failed. Enabled debug logging on the agent, forced the update and it worked. I have no idea why.
Author
Owner

@NiceGuyIT commented on GitHub (Sep 26, 2022):

Here are the exact steps. The remaining agents were able to update without problems using these procedures.

  1. Run script on agent: TacticalRMM - TRMM Agent enable Debug Mode
    • Choose Fire and Forget because you will never get the output.
  2. Agents > Update Agents > select the agents > Update
  3. Wait a minute and refresh the data. The agents are now on the latest (v2.4.0)
  4. Run script on agent: TacticalRMM - TRMM Agent disable Debug Mode
    • Choose Fire and Forget because you will never get the output.
<!-- gh-comment-id:1258403648 --> @NiceGuyIT commented on GitHub (Sep 26, 2022): Here are the exact steps. The remaining agents were able to update without problems using these procedures. 1. Run script on agent: TacticalRMM - TRMM Agent enable Debug Mode - Choose Fire and Forget because you will never get the output. 3. Agents > Update Agents > select the agents > Update 4. Wait a minute and refresh the data. The agents are now on the latest (v2.4.0) 5. Run script on agent: TacticalRMM - TRMM Agent disable Debug Mode - Choose Fire and Forget because you will never get the output.
Author
Owner

@silversword411 commented on GitHub (Sep 26, 2022):

It's using the wrong directories, those are pre....would have to check version

2022-09-26 12:35:05.178 Created temporary directory: C:\WINDOWS\TEMP\is-K7G4F.tmp

What agent version those running?

Also https://github.com/amidaware/tacticalrmm/issues/1238

<!-- gh-comment-id:1258506416 --> @silversword411 commented on GitHub (Sep 26, 2022): It's using the wrong directories, those are pre....would have to check version `2022-09-26 12:35:05.178 Created temporary directory: C:\WINDOWS\TEMP\is-K7G4F.tmp` What agent version those running? Also https://github.com/amidaware/tacticalrmm/issues/1238
Author
Owner

@NiceGuyIT commented on GitHub (Sep 26, 2022):

What agent version those running?

That's above, v2.2.1 trying to upgrade to v2.4.0.

Even still, turning on debug mode makes everything work. Restarting without debug mode enabled and it fails. That's what makes this puzzling.

<!-- gh-comment-id:1258535927 --> @NiceGuyIT commented on GitHub (Sep 26, 2022): > What agent version those running? That's above, v2.2.1 trying to upgrade to v2.4.0. Even still, turning on debug mode makes everything work. Restarting without debug mode enabled and it fails. That's what makes this puzzling.
Author
Owner

@silversword411 commented on GitHub (Sep 26, 2022):

turning on debug mode makes everything work

Yeah, that's weird...must be some interaction with the temp ACL permissions somehow?

<!-- gh-comment-id:1258554865 --> @silversword411 commented on GitHub (Sep 26, 2022): > turning on debug mode makes everything work Yeah, that's weird...must be some interaction with the temp ACL permissions somehow?
Author
Owner

@silversword411 commented on GitHub (Sep 26, 2022):

  1. TRMM Agent enable Debug Mode

Good to hear those are working....was actually planning on coming back to them to check...maybe rebuild with registry edits instead of one-off cmd launches :)

For you, probably don't need to de-debug mode since it's restarting service on install

<!-- gh-comment-id:1258566716 --> @silversword411 commented on GitHub (Sep 26, 2022): > 1. TRMM Agent enable Debug Mode Good to hear those are working....was actually planning on coming back to them to check...maybe rebuild with registry edits instead of one-off cmd launches :) For you, probably don't need to de-debug mode since it's restarting service on install
Author
Owner

@NiceGuyIT commented on GitHub (Nov 1, 2022):

I updated last night to v0.15.2, agent v2.4.1 and it seems most or all the Windows 10 devices did not update. Windows server agents updated. Since enabling debug mode makes the update work, what can I do to gather logs without enabling debug mode?

<!-- gh-comment-id:1298576507 --> @NiceGuyIT commented on GitHub (Nov 1, 2022): I updated last night to v0.15.2, agent v2.4.1 and it seems most or all the Windows 10 devices did not update. Windows server agents updated. Since enabling debug mode makes the update work, what can I do to gather logs without enabling debug mode?
Author
Owner

@silversword411 commented on GitHub (Nov 4, 2022):

Have you tried:

  • restart agent OS
  • delete temp files in windows
  • Manually trigger update on one agent
  • Check for log files in %windir%\temp\cantrememberthepage and c:\ProgramData\TacticalRMM\
  • Check for double-stuck setup? I haven't see the issue here, but I haven't been watching that close lately
<!-- gh-comment-id:1303051183 --> @silversword411 commented on GitHub (Nov 4, 2022): Have you tried: - restart agent OS - delete temp files in windows - Manually trigger update on one agent - Check for log files in %windir%\temp\cantrememberthepage and c:\ProgramData\TacticalRMM\ - Check for double-stuck setup? I haven't see the issue here, but I haven't been watching that close lately
Author
Owner

@NiceGuyIT commented on GitHub (Nov 5, 2022):

Enabling debugging via script command runs the agent as a process, not a service. That's why enabling debugging allows the agent to update.

To troubleshoot this, the log level was changed for the service itself. First, get the current command line.

Get-ItemPropertyValue -Path 'HKLM:\System\CurrentControlSet\Services\tacticalrmm\' -Name ImagePath

Set log level to trace.

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Services\tacticalrmm\' -Name ImagePath -Value '"C
:\Program Files\TacticalAgent\tacticalrmm.exe" -m svc -log trace'

Verify the new command.

Get-ItemPropertyValue -Path 'HKLM:\System\CurrentControlSet\Services\tacticalrmm\' -Name ImagePath

And then restart the service.

Restart-Service -Name tacticalrmm

With debug logging enabled, an update was pushed. The complete logs are below. The Event Viewer log shows the service was restarted because it terminated unexpectedly.

Log Name:      System
Source:        Service Control Manager
Date:          11/5/2022 4:12:41 PM
Event ID:      7031
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      PC-Video1
Description:
The TacticalRMM Agent Service service terminated unexpectedly.  It has done this 1 time(s).  The following corrective action will be taken in 5000 milliseconds: Restart the service.

Here's the timeline of events. The code has a 1 second delay between "Agent updating" and os.Exit(0) in rpc.go. Without millisecond logging to confirm, it seems the os.Exit(0) is causing Windows to think the service terminated unexpectedly.

time="2022-11-05T16:11:59-04:00" level=debug msg=--------------------------------
time="2022-11-05T16:12:26-04:00" level=debug msg="agent-hello {**************************************** 2.4.0}"
time="2022-11-05T16:12:38-04:00" level=debug msg="killing process C:\\ProgramData\\TacticalRMM\\tacticalagent-v2.4.1-windows-amd64.exe"
time="2022-11-05T16:12:38-04:00" level=debug msg="killing process C:\\Windows\\Temp\\is-DIF76.tmp\\tacticalagent-v2.4.1-windows-amd64.tmp"
time="2022-11-05T16:12:39-04:00" level=debug msg="CleanupAgentUpdates() Removing file: tacticalagent-v2.4.1-windows-amd64.exe"
time="2022-11-05T16:12:39-04:00" level=info msg="Agent updating from 2.4.0 to 2.4.1"
11/5/2022 4:12:41 PM The TacticalRMM Agent Service service terminated unexpectedly.
2022-11-05 16:12:41.388   Log opened. (Time zone: UTC-04:00)
2022-11-05 16:12:41.388   Setup version: Inno Setup version 6.2.1
time="2022-11-05T16:12:46-04:00" level=info msg="Agent service started"
2022-11-05 16:12:45.606   Installing the file.
2022-11-05 16:12:57.683   DeleteFile: The existing file appears to be in use (5). Retrying.
tacticalagent_update_v2.4.1.txt
2022-11-05 16:12:41.388   Log opened. (Time zone: UTC-04:00)
2022-11-05 16:12:41.388   Setup version: Inno Setup version 6.2.1
2022-11-05 16:12:41.388   Original Setup EXE: C:\ProgramData\TacticalRMM\tacticalagent-v2.4.1-windows-amd64.exe
2022-11-05 16:12:41.388   Setup command line: /SL5="$1B00D2,3441392,825344,C:\ProgramData\TacticalRMM\tacticalagent-v2.4.1-windows-amd64.exe" /VERYSILENT /LOG=C:\ProgramData\TacticalRMM\tacticalagent_update_v2.4.1.txt
2022-11-05 16:12:41.388   Windows version: 10.0.19043  (NT platform: Yes)
2022-11-05 16:12:41.388   64-bit Windows: Yes
2022-11-05 16:12:41.388   Processor architecture: x64
2022-11-05 16:12:41.388   User privileges: Administrative
2022-11-05 16:12:41.388   Administrative install mode: Yes
2022-11-05 16:12:41.388   Install mode root key: HKEY_LOCAL_MACHINE
2022-11-05 16:12:41.388   64-bit install mode: No
2022-11-05 16:12:41.403   Created temporary directory: C:\WINDOWS\TEMP\is-HKSAV.tmp
2022-11-05 16:12:42.825   Stop tacticalrpc: 2
2022-11-05 16:12:43.169   Stop tacticalagent: 2
2022-11-05 16:12:44.512   Stop tacticalrmm: 2
2022-11-05 16:12:44.887   taskkill: 128
2022-11-05 16:12:45.059   delete tacticalagent: 1060
2022-11-05 16:12:45.262   delete tacticalrpc: 1060
2022-11-05 16:12:45.372   Starting the installation process.
2022-11-05 16:12:45.372   Directory for uninstall files: C:\Program Files\TacticalAgent
2022-11-05 16:12:45.372   Will append to existing uninstall log: C:\Program Files\TacticalAgent\unins000.dat
2022-11-05 16:12:45.387   -- File entry --
2022-11-05 16:12:45.387   Dest filename: C:\Program Files\TacticalAgent\unins000.exe
2022-11-05 16:12:45.403   Time stamp of our file: 2022-11-05 16:12:40.610
2022-11-05 16:12:45.403   Dest file exists.
2022-11-05 16:12:45.403   Time stamp of existing file: 2022-09-26 13:13:48.371
2022-11-05 16:12:45.403   Version of our file: 51.1052.0.0
2022-11-05 16:12:45.403   Version of existing file: 51.1052.0.0
2022-11-05 16:12:45.403   Installing the file.
2022-11-05 16:12:45.606   Leaving temporary file in place for now.
2022-11-05 16:12:45.606   -- File entry --
2022-11-05 16:12:45.606   Dest filename: C:\Program Files\TacticalAgent\tacticalrmm.exe
2022-11-05 16:12:45.606   Time stamp of our file: 2022-10-25 14:52:00.000
2022-11-05 16:12:45.606   Dest file exists.
2022-11-05 16:12:45.606   Time stamp of existing file: 2022-09-23 19:19:32.000
2022-11-05 16:12:45.606   Installing the file.
2022-11-05 16:12:57.683   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-11-05 16:12:58.698   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-11-05 16:12:59.714   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-11-05 16:13:00.729   DeleteFile: The existing file appears to be in use (5). Retrying.
2022-11-05 16:13:01.745   Message box (Abort/Retry/Ignore):
                          C:\Program Files\TacticalAgent\tacticalrmm.exe
                          
                          An error occurred while trying to replace the existing file:
                          DeleteFile failed; code 5.
                          Access is denied.
agent.log
time="2022-11-05T16:11:59-04:00" level=debug msg=--------------------------------
time="2022-11-05T16:12:26-04:00" level=debug msg="agent-hello {**************************************** 2.4.0}"
time="2022-11-05T16:12:38-04:00" level=debug msg="killing process C:\\ProgramData\\TacticalRMM\\tacticalagent-v2.4.1-windows-amd64.exe"
time="2022-11-05T16:12:38-04:00" level=debug msg="killing process C:\\Windows\\Temp\\is-DIF76.tmp\\tacticalagent-v2.4.1-windows-amd64.tmp"
time="2022-11-05T16:12:39-04:00" level=debug msg="CleanupAgentUpdates() Removing file: tacticalagent-v2.4.1-windows-amd64.exe"
time="2022-11-05T16:12:39-04:00" level=info msg="Agent updating from 2.4.0 to 2.4.1"
time="2022-11-05T16:12:39-04:00" level=debug msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.4.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services"
time="2022-11-05T16:12:46-04:00" level=debug msg="{Hostname:PC-Video1 Arch: AgentID:**************************************** BaseURL:https://api.smb.services ApiURL:api.smb.services Token:**************************************** AgentPK:10 Cert: ProgramDir:C:\\Program Files\\TacticalAgent EXE:C:\\Program Files\\TacticalAgent\\tacticalrmm.exe SystemDrive:C: MeshInstaller:meshagent.exe MeshSystemEXE:C:\\Program Files\\Mesh Agent\\MeshAgent.exe MeshSVC:mesh agent PyBin:C:\\Program Files\\TacticalAgent\\py38-x64\\python.exe Headers:map[Authorization:Token **************************************** Content-Type:application/json] Logger:0xc00005c080 Version:2.4.0 Debug:true rClient:0xc0000001e0 Proxy: LogTo: LogFile:<nil> Platform:windows GoArch:amd64 ServiceConfig:0xc000068160 NatsServer:wss://api.smb.services:443 NatsProxyPath:natsws NatsProxyPort:443}\n"
time="2022-11-05T16:12:46-04:00" level=info msg="Agent service started"
time="2022-11-05T16:12:46-04:00" level=debug msg="CheckRunner() init sleeping for 19 seconds"
time="2022-11-05T16:12:46-04:00" level=debug msg="AgentSvc() sleeping for 19 seconds"
time="2022-11-05T16:13:05-04:00" level=debug msg="agent-hello {**************************************** 2.4.0}"
time="2022-11-05T16:13:05-04:00" level=debug msg="[C:\\ProgramData\\TacticalRMM\\908886251.py]"
time="2022-11-05T16:13:06-04:00" level=debug msg="agent-agentinfo {**************************************** PC-User PC-Video1 Windows 10 Pro, 64 bit v21H1 (build 19043.2130) windows 4 1667613696 false amd64}"
time="2022-11-05T16:13:06-04:00" level=debug msg="agent-disks {**************************************** [{C: NTFS 58.3 GB 32.2 GB 26.1 GB 55}]}"
<!-- gh-comment-id:1304638535 --> @NiceGuyIT commented on GitHub (Nov 5, 2022): Enabling debugging via script command runs the agent as a process, not a service. That's why enabling debugging allows the agent to update. To troubleshoot this, the log level was changed for the service itself. First, get the current command line. ```PowerShell Get-ItemPropertyValue -Path 'HKLM:\System\CurrentControlSet\Services\tacticalrmm\' -Name ImagePath ``` Set log level to trace. ```PowerShell Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Services\tacticalrmm\' -Name ImagePath -Value '"C :\Program Files\TacticalAgent\tacticalrmm.exe" -m svc -log trace' ``` Verify the new command. ```PowerShell Get-ItemPropertyValue -Path 'HKLM:\System\CurrentControlSet\Services\tacticalrmm\' -Name ImagePath ``` And then restart the service. ```PowerShell Restart-Service -Name tacticalrmm ``` With debug logging enabled, an update was pushed. The complete logs are below. The Event Viewer log shows the service was restarted because it terminated unexpectedly. ```text Log Name: System Source: Service Control Manager Date: 11/5/2022 4:12:41 PM Event ID: 7031 Task Category: None Level: Error Keywords: Classic User: N/A Computer: PC-Video1 Description: The TacticalRMM Agent Service service terminated unexpectedly. It has done this 1 time(s). The following corrective action will be taken in 5000 milliseconds: Restart the service. ``` Here's the timeline of events. The code has a 1 second delay between "Agent updating" and `os.Exit(0)` in `rpc.go`. Without millisecond logging to confirm, it seems the `os.Exit(0)` is causing Windows to think the service terminated unexpectedly. ```text time="2022-11-05T16:11:59-04:00" level=debug msg=-------------------------------- time="2022-11-05T16:12:26-04:00" level=debug msg="agent-hello {**************************************** 2.4.0}" time="2022-11-05T16:12:38-04:00" level=debug msg="killing process C:\\ProgramData\\TacticalRMM\\tacticalagent-v2.4.1-windows-amd64.exe" time="2022-11-05T16:12:38-04:00" level=debug msg="killing process C:\\Windows\\Temp\\is-DIF76.tmp\\tacticalagent-v2.4.1-windows-amd64.tmp" time="2022-11-05T16:12:39-04:00" level=debug msg="CleanupAgentUpdates() Removing file: tacticalagent-v2.4.1-windows-amd64.exe" time="2022-11-05T16:12:39-04:00" level=info msg="Agent updating from 2.4.0 to 2.4.1" 11/5/2022 4:12:41 PM The TacticalRMM Agent Service service terminated unexpectedly. 2022-11-05 16:12:41.388 Log opened. (Time zone: UTC-04:00) 2022-11-05 16:12:41.388 Setup version: Inno Setup version 6.2.1 time="2022-11-05T16:12:46-04:00" level=info msg="Agent service started" 2022-11-05 16:12:45.606 Installing the file. 2022-11-05 16:12:57.683 DeleteFile: The existing file appears to be in use (5). Retrying. ``` <details> <summary>tacticalagent_update_v2.4.1.txt</summary> ```text 2022-11-05 16:12:41.388 Log opened. (Time zone: UTC-04:00) 2022-11-05 16:12:41.388 Setup version: Inno Setup version 6.2.1 2022-11-05 16:12:41.388 Original Setup EXE: C:\ProgramData\TacticalRMM\tacticalagent-v2.4.1-windows-amd64.exe 2022-11-05 16:12:41.388 Setup command line: /SL5="$1B00D2,3441392,825344,C:\ProgramData\TacticalRMM\tacticalagent-v2.4.1-windows-amd64.exe" /VERYSILENT /LOG=C:\ProgramData\TacticalRMM\tacticalagent_update_v2.4.1.txt 2022-11-05 16:12:41.388 Windows version: 10.0.19043 (NT platform: Yes) 2022-11-05 16:12:41.388 64-bit Windows: Yes 2022-11-05 16:12:41.388 Processor architecture: x64 2022-11-05 16:12:41.388 User privileges: Administrative 2022-11-05 16:12:41.388 Administrative install mode: Yes 2022-11-05 16:12:41.388 Install mode root key: HKEY_LOCAL_MACHINE 2022-11-05 16:12:41.388 64-bit install mode: No 2022-11-05 16:12:41.403 Created temporary directory: C:\WINDOWS\TEMP\is-HKSAV.tmp 2022-11-05 16:12:42.825 Stop tacticalrpc: 2 2022-11-05 16:12:43.169 Stop tacticalagent: 2 2022-11-05 16:12:44.512 Stop tacticalrmm: 2 2022-11-05 16:12:44.887 taskkill: 128 2022-11-05 16:12:45.059 delete tacticalagent: 1060 2022-11-05 16:12:45.262 delete tacticalrpc: 1060 2022-11-05 16:12:45.372 Starting the installation process. 2022-11-05 16:12:45.372 Directory for uninstall files: C:\Program Files\TacticalAgent 2022-11-05 16:12:45.372 Will append to existing uninstall log: C:\Program Files\TacticalAgent\unins000.dat 2022-11-05 16:12:45.387 -- File entry -- 2022-11-05 16:12:45.387 Dest filename: C:\Program Files\TacticalAgent\unins000.exe 2022-11-05 16:12:45.403 Time stamp of our file: 2022-11-05 16:12:40.610 2022-11-05 16:12:45.403 Dest file exists. 2022-11-05 16:12:45.403 Time stamp of existing file: 2022-09-26 13:13:48.371 2022-11-05 16:12:45.403 Version of our file: 51.1052.0.0 2022-11-05 16:12:45.403 Version of existing file: 51.1052.0.0 2022-11-05 16:12:45.403 Installing the file. 2022-11-05 16:12:45.606 Leaving temporary file in place for now. 2022-11-05 16:12:45.606 -- File entry -- 2022-11-05 16:12:45.606 Dest filename: C:\Program Files\TacticalAgent\tacticalrmm.exe 2022-11-05 16:12:45.606 Time stamp of our file: 2022-10-25 14:52:00.000 2022-11-05 16:12:45.606 Dest file exists. 2022-11-05 16:12:45.606 Time stamp of existing file: 2022-09-23 19:19:32.000 2022-11-05 16:12:45.606 Installing the file. 2022-11-05 16:12:57.683 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-11-05 16:12:58.698 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-11-05 16:12:59.714 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-11-05 16:13:00.729 DeleteFile: The existing file appears to be in use (5). Retrying. 2022-11-05 16:13:01.745 Message box (Abort/Retry/Ignore): C:\Program Files\TacticalAgent\tacticalrmm.exe An error occurred while trying to replace the existing file: DeleteFile failed; code 5. Access is denied. ``` </details> <details> <summary>agent.log</summary> ```text time="2022-11-05T16:11:59-04:00" level=debug msg=-------------------------------- time="2022-11-05T16:12:26-04:00" level=debug msg="agent-hello {**************************************** 2.4.0}" time="2022-11-05T16:12:38-04:00" level=debug msg="killing process C:\\ProgramData\\TacticalRMM\\tacticalagent-v2.4.1-windows-amd64.exe" time="2022-11-05T16:12:38-04:00" level=debug msg="killing process C:\\Windows\\Temp\\is-DIF76.tmp\\tacticalagent-v2.4.1-windows-amd64.tmp" time="2022-11-05T16:12:39-04:00" level=debug msg="CleanupAgentUpdates() Removing file: tacticalagent-v2.4.1-windows-amd64.exe" time="2022-11-05T16:12:39-04:00" level=info msg="Agent updating from 2.4.0 to 2.4.1" time="2022-11-05T16:12:39-04:00" level=debug msg="Downloading agent update from https://agents.tacticalrmm.com/api/v2/agents/?version=2.4.1&arch=amd64&token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&plat=windows&api=api.smb.services" time="2022-11-05T16:12:46-04:00" level=debug msg="{Hostname:PC-Video1 Arch: AgentID:**************************************** BaseURL:https://api.smb.services ApiURL:api.smb.services Token:**************************************** AgentPK:10 Cert: ProgramDir:C:\\Program Files\\TacticalAgent EXE:C:\\Program Files\\TacticalAgent\\tacticalrmm.exe SystemDrive:C: MeshInstaller:meshagent.exe MeshSystemEXE:C:\\Program Files\\Mesh Agent\\MeshAgent.exe MeshSVC:mesh agent PyBin:C:\\Program Files\\TacticalAgent\\py38-x64\\python.exe Headers:map[Authorization:Token **************************************** Content-Type:application/json] Logger:0xc00005c080 Version:2.4.0 Debug:true rClient:0xc0000001e0 Proxy: LogTo: LogFile:<nil> Platform:windows GoArch:amd64 ServiceConfig:0xc000068160 NatsServer:wss://api.smb.services:443 NatsProxyPath:natsws NatsProxyPort:443}\n" time="2022-11-05T16:12:46-04:00" level=info msg="Agent service started" time="2022-11-05T16:12:46-04:00" level=debug msg="CheckRunner() init sleeping for 19 seconds" time="2022-11-05T16:12:46-04:00" level=debug msg="AgentSvc() sleeping for 19 seconds" time="2022-11-05T16:13:05-04:00" level=debug msg="agent-hello {**************************************** 2.4.0}" time="2022-11-05T16:13:05-04:00" level=debug msg="[C:\\ProgramData\\TacticalRMM\\908886251.py]" time="2022-11-05T16:13:06-04:00" level=debug msg="agent-agentinfo {**************************************** PC-User PC-Video1 Windows 10 Pro, 64 bit v21H1 (build 19043.2130) windows 4 1667613696 false amd64}" time="2022-11-05T16:13:06-04:00" level=debug msg="agent-disks {**************************************** [{C: NTFS 58.3 GB 32.2 GB 26.1 GB 55}]}" ``` </details>
Author
Owner

@NiceGuyIT commented on GitHub (Nov 5, 2022):

This fixes the problem for me. It uses Tactical's ControlService function to stop itself and doesn't trigger the Windows event log.

diff --git a/agent/rpc.go b/agent/rpc.go
index ce2a89c..3b26341 100644
--- a/agent/rpc.go
+++ b/agent/rpc.go
@@ -479,6 +479,7 @@ func (a *Agent) RunRPC() {
                                        atomic.StoreUint32(&agentUpdateLocker, 0)
                                        nc.Flush()
                                        nc.Close()
+                                       a.ControlService("tacticalrmm", "stop")
                                        os.Exit(0)
                                }
                        }(payload)

As for how to stop a Windows service properly, I found this issue in Kubernetes.

Changes the failure actions flag setting of a service. If this setting is 0 (default), the Service Control Manager
(SCM) enables configured failure actions on the service only if the service process terminates with the service in
a state other than SERVICE_STOPPED. If this setting is 1, the SCM enables configured failure actions on the service if the service enters the SERVICE_STOPPED state with a Win32 exit code other than 0 in addition to the service process termination as above. This setting is ignored if the service does not have any failure actions configured.

It looks like we send svc.Stopped and then os.Exit(0), but the official golang example sends svc.StopPending and just returns without exiting. (https://github.com/golang/sys/blob/master/windows/svc/example/service.go#L57). Is this difference meaningful?

I also found this SO question to Gracefully terminate a process on Windows where someone mentioned:

The proper way to get notified if you are a service is the service handler of your console application (SERVICE_STOPPED). For more, see Writing a ServiceMain.

For context, I use Bitdefender GravityZone. This could introduce additional latency that is causing this race condition.

<!-- gh-comment-id:1304644612 --> @NiceGuyIT commented on GitHub (Nov 5, 2022): This fixes the problem for me. It uses Tactical's `ControlService` function to stop itself and doesn't trigger the Windows event log. ```patch diff --git a/agent/rpc.go b/agent/rpc.go index ce2a89c..3b26341 100644 --- a/agent/rpc.go +++ b/agent/rpc.go @@ -479,6 +479,7 @@ func (a *Agent) RunRPC() { atomic.StoreUint32(&agentUpdateLocker, 0) nc.Flush() nc.Close() + a.ControlService("tacticalrmm", "stop") os.Exit(0) } }(payload) ``` As for how to stop a Windows service properly, I found this [issue](https://github.com/kubernetes/kubernetes/issues/72900) in Kubernetes. > > Changes the failure actions flag setting of a service. If this setting is 0 (default), the Service Control Manager (SCM) enables configured failure actions on the service only if the service process terminates with the service in a state other than SERVICE_STOPPED. If this setting is 1, the SCM enables configured failure actions on the service if the service enters the SERVICE_STOPPED state with a Win32 exit code other than 0 in addition to the service process termination as above. This setting is ignored if the service does not have any failure actions configured. > > It looks like we send svc.Stopped and then os.Exit(0), but the official golang example sends svc.StopPending and just returns without exiting. (https://github.com/golang/sys/blob/master/windows/svc/example/service.go#L57). Is this difference meaningful? I also found this SO question to [Gracefully terminate a process on Windows](https://stackoverflow.com/questions/55092139/gracefully-terminate-a-process-on-windows) where [someone mentioned](https://stackoverflow.com/a/62754842): > The proper way to get notified if you are a service is the service handler of your console application (SERVICE_STOPPED). For more, see [Writing a ServiceMain](https://learn.microsoft.com/en-us/windows/win32/services/writing-a-servicemain-function). For context, I use Bitdefender GravityZone. This could introduce additional latency that is causing this race condition.
Author
Owner

@NiceGuyIT commented on GitHub (Nov 6, 2022):

Here's the timeline for Windows Server which does not have Bitdefender and updated successfully. The event logs have the same error but the install was a little faster. About 4 seconds for both systems to run the install, but the one above is a little slower causing the service to restart just before the installer tries to replace the file.

time="2022-10-31T18:58:51-07:00" level=info msg="Agent updating from 2.4.0 to 2.4.1"
10/31/2022 6:58:54 PM The TacticalRMM Agent Service service terminated unexpectedly.
2022-10-31 18:58:54.319   Log opened. (Time zone: UTC-07:00)
2022-10-31 18:58:54.319   Setup version: Inno Setup version 6.2.1
2022-10-31 18:58:54.319   Original Setup EXE: C:\ProgramData\TacticalRMM\tacticalagent-v2.4.1-windows-amd64.exe
2022-10-31 18:58:54.319   Setup command line: /SL5="$26B80042,3441392,825344,C:\ProgramData\TacticalRMM\tacticalagent-v2.4.1-windows-amd64.exe" /VERYSILENT /LOG=C:\ProgramData\TacticalRMM\tacticalagent_update_v2.4.1.txt
2022-10-31 18:58:54.319   Windows version: 10.0.17763  (NT platform: Yes)
2022-10-31 18:58:54.319   64-bit Windows: Yes
2022-10-31 18:58:54.319   Processor architecture: x64
2022-10-31 18:58:54.319   User privileges: Administrative
2022-10-31 18:58:54.319   Administrative install mode: Yes
2022-10-31 18:58:54.319   Install mode root key: HKEY_LOCAL_MACHINE
2022-10-31 18:58:54.319   64-bit install mode: No
2022-10-31 18:58:54.319   Created temporary directory: C:\Windows\TEMP\is-A3D4R.tmp
2022-10-31 18:58:55.814   Stop tacticalrpc: 2
2022-10-31 18:58:55.931   Stop tacticalagent: 2
2022-10-31 18:58:57.058   Stop tacticalrmm: 2
2022-10-31 18:58:57.262   taskkill: 0
2022-10-31 18:58:57.340   delete tacticalagent: 1060
2022-10-31 18:58:57.402   delete tacticalrpc: 1060
2022-10-31 18:58:57.558   Starting the installation process.
2022-10-31 18:58:57.558   Directory for uninstall files: C:\Program Files\TacticalAgent
2022-10-31 18:58:57.558   Will append to existing uninstall log: C:\Program Files\TacticalAgent\unins000.dat
2022-10-31 18:58:57.590   -- File entry --
2022-10-31 18:58:57.590   Dest filename: C:\Program Files\TacticalAgent\unins000.exe
2022-10-31 18:58:57.621   Time stamp of our file: 2022-10-31 18:58:53.893
2022-10-31 18:58:57.621   Dest file exists.
2022-10-31 18:58:57.621   Time stamp of existing file: 2022-09-25 19:30:35.126
2022-10-31 18:58:57.621   Version of our file: 51.1052.0.0
2022-10-31 18:58:57.621   Version of existing file: 51.1052.0.0
2022-10-31 18:58:57.621   Installing the file.
2022-10-31 18:58:57.621   Leaving temporary file in place for now.
2022-10-31 18:58:57.621   -- File entry --
2022-10-31 18:58:57.621   Dest filename: C:\Program Files\TacticalAgent\tacticalrmm.exe
2022-10-31 18:58:57.621   Time stamp of our file: 2022-10-25 14:52:00.000
2022-10-31 18:58:57.621   Dest file exists.
2022-10-31 18:58:57.621   Time stamp of existing file: 2022-09-23 19:19:32.000
2022-10-31 18:58:57.621   Installing the file.
2022-10-31 18:58:57.871   Successfully installed the file.
2022-10-31 18:58:57.871   Saving uninstall information.
2022-10-31 18:58:57.871   Renaming uninstaller.
2022-10-31 18:58:57.871   Deleting uninstall key left over from previous administrative 32-bit install.
2022-10-31 18:58:57.871   Creating new uninstall key: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\{0D34D278-5FAF-4159-A4A0-4E2D2C08139D}_is1
2022-10-31 18:58:57.871   Writing uninstall key values.
2022-10-31 18:58:57.871   Detected previous non administrative install? No
2022-10-31 18:58:57.871   Detected previous administrative 64-bit install? No
2022-10-31 18:58:57.887   Installation process succeeded.
2022-10-31 18:58:57.887   Need to restart Windows? No
2022-10-31 18:58:57.887   Deinitializing Setup.
2022-10-31 18:58:58.002   install service: 0
time="2022-10-31T18:58:58-07:00" level=info msg="Agent service started"
2022-10-31 18:59:00.159   Start tacticalrmm: 0
2022-10-31 18:59:00.159   Log closed.
<!-- gh-comment-id:1304691561 --> @NiceGuyIT commented on GitHub (Nov 6, 2022): Here's the timeline for Windows Server which does not have Bitdefender and updated successfully. The event logs have the same error but the install was a little faster. About 4 seconds for both systems to run the install, but the one above is a little slower causing the service to restart just before the installer tries to replace the file. ```text time="2022-10-31T18:58:51-07:00" level=info msg="Agent updating from 2.4.0 to 2.4.1" 10/31/2022 6:58:54 PM The TacticalRMM Agent Service service terminated unexpectedly. 2022-10-31 18:58:54.319 Log opened. (Time zone: UTC-07:00) 2022-10-31 18:58:54.319 Setup version: Inno Setup version 6.2.1 2022-10-31 18:58:54.319 Original Setup EXE: C:\ProgramData\TacticalRMM\tacticalagent-v2.4.1-windows-amd64.exe 2022-10-31 18:58:54.319 Setup command line: /SL5="$26B80042,3441392,825344,C:\ProgramData\TacticalRMM\tacticalagent-v2.4.1-windows-amd64.exe" /VERYSILENT /LOG=C:\ProgramData\TacticalRMM\tacticalagent_update_v2.4.1.txt 2022-10-31 18:58:54.319 Windows version: 10.0.17763 (NT platform: Yes) 2022-10-31 18:58:54.319 64-bit Windows: Yes 2022-10-31 18:58:54.319 Processor architecture: x64 2022-10-31 18:58:54.319 User privileges: Administrative 2022-10-31 18:58:54.319 Administrative install mode: Yes 2022-10-31 18:58:54.319 Install mode root key: HKEY_LOCAL_MACHINE 2022-10-31 18:58:54.319 64-bit install mode: No 2022-10-31 18:58:54.319 Created temporary directory: C:\Windows\TEMP\is-A3D4R.tmp 2022-10-31 18:58:55.814 Stop tacticalrpc: 2 2022-10-31 18:58:55.931 Stop tacticalagent: 2 2022-10-31 18:58:57.058 Stop tacticalrmm: 2 2022-10-31 18:58:57.262 taskkill: 0 2022-10-31 18:58:57.340 delete tacticalagent: 1060 2022-10-31 18:58:57.402 delete tacticalrpc: 1060 2022-10-31 18:58:57.558 Starting the installation process. 2022-10-31 18:58:57.558 Directory for uninstall files: C:\Program Files\TacticalAgent 2022-10-31 18:58:57.558 Will append to existing uninstall log: C:\Program Files\TacticalAgent\unins000.dat 2022-10-31 18:58:57.590 -- File entry -- 2022-10-31 18:58:57.590 Dest filename: C:\Program Files\TacticalAgent\unins000.exe 2022-10-31 18:58:57.621 Time stamp of our file: 2022-10-31 18:58:53.893 2022-10-31 18:58:57.621 Dest file exists. 2022-10-31 18:58:57.621 Time stamp of existing file: 2022-09-25 19:30:35.126 2022-10-31 18:58:57.621 Version of our file: 51.1052.0.0 2022-10-31 18:58:57.621 Version of existing file: 51.1052.0.0 2022-10-31 18:58:57.621 Installing the file. 2022-10-31 18:58:57.621 Leaving temporary file in place for now. 2022-10-31 18:58:57.621 -- File entry -- 2022-10-31 18:58:57.621 Dest filename: C:\Program Files\TacticalAgent\tacticalrmm.exe 2022-10-31 18:58:57.621 Time stamp of our file: 2022-10-25 14:52:00.000 2022-10-31 18:58:57.621 Dest file exists. 2022-10-31 18:58:57.621 Time stamp of existing file: 2022-09-23 19:19:32.000 2022-10-31 18:58:57.621 Installing the file. 2022-10-31 18:58:57.871 Successfully installed the file. 2022-10-31 18:58:57.871 Saving uninstall information. 2022-10-31 18:58:57.871 Renaming uninstaller. 2022-10-31 18:58:57.871 Deleting uninstall key left over from previous administrative 32-bit install. 2022-10-31 18:58:57.871 Creating new uninstall key: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\{0D34D278-5FAF-4159-A4A0-4E2D2C08139D}_is1 2022-10-31 18:58:57.871 Writing uninstall key values. 2022-10-31 18:58:57.871 Detected previous non administrative install? No 2022-10-31 18:58:57.871 Detected previous administrative 64-bit install? No 2022-10-31 18:58:57.887 Installation process succeeded. 2022-10-31 18:58:57.887 Need to restart Windows? No 2022-10-31 18:58:57.887 Deinitializing Setup. 2022-10-31 18:58:58.002 install service: 0 time="2022-10-31T18:58:58-07:00" level=info msg="Agent service started" 2022-10-31 18:59:00.159 Start tacticalrmm: 0 2022-10-31 18:59:00.159 Log closed. ```
Author
Owner

@wh1te909 commented on GitHub (Nov 7, 2022):

thank you, can confirm adding the control service line fixes the issue, will be in next release

<!-- gh-comment-id:1305143171 --> @wh1te909 commented on GitHub (Nov 7, 2022): thank you, can confirm adding the control service line fixes the issue, will be in next release
Author
Owner

@silversword411 commented on GitHub (Nov 10, 2022):

Closing...in anticipation of release-and-fix.

<!-- gh-comment-id:1310286102 --> @silversword411 commented on GitHub (Nov 10, 2022): Closing...in anticipation of release-and-fix.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tacticalrmm#2717
No description provided.