Bill-Stewart / SyncthingWindowsSetup

Syncthing Windows Setup
Mozilla Public License 2.0
1.07k stars 44 forks source link

Delete folder SyncthingServiceAcct #27

Closed steroeck closed 5 months ago

steroeck commented 5 months ago

After uninstalling Syncthing on Windows 10 it is impossible to delete the folder /Users/SyncthingServiceAcct and all files within it. Even with admin rights it is not possible - windows says I don't have enough access rights. For example:

PS C:\Users> rm .\SyncthingServiceAcct\ntuser.dat.LOG2
rm : Das Element C:\Users\SyncthingServiceAcct\ntuser.dat.LOG2 kann nicht entfernt werden: Sie besitzen keine ausreichenden Zugriffsberechtigungen zum Ausführen dieses Vorgangs.
In Zeile:1 Zeichen:1
+ rm .\SyncthingServiceAcct\ntuser.dat.LOG2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Users\Syncth...ntuser.dat.LOG2:FileInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand

I have already deleted the service account with:

net user "SyncthingServiceAcct" /delete

Any idea what I should do?

Bill-Stewart commented 5 months ago

Your question is "How do I delete a user profile?"

https://learn.microsoft.com/en-us/troubleshoot/windows-server/user-profiles-and-logon/delete-user-profile

steroeck commented 5 months ago

Thanks for replying!

The description in your link on "How do I delete a user profile?" does not work. In point 5 of the link says "In the next dialog, there is a list of profiles on the system. Select the profile that you want to remove and select Delete". If I select the user account for SyncthingServiceAcct the "Delete" button is greyed out - so I can't click on it (note: I have admin rights!).

If I delete the account with

net user "SyncthingServiceAcct" /delete

The account does not appear anymore in the dialog, described in your link - so I have deleted the account!

Still, I can't delete the folder "/Users/SyncthingServiceAcct" - I have no permission. Or maybe some part of Syncthing which was not uninstalled correctly is still accessing the folder.

So, I have two questions:

  1. Why is the uninstaller of Syncthing not removing everything from the system it has installed (program, user service account including the user account folder)?
  2. If, for some reason, it is not possible to automatically uninstall the user account including the account folder ("/Users/SyncthingServiceAcct"), how can I remove it manually?
Bill-Stewart commented 5 months ago
  1. The creation of the SyncthingServiceAcct account is provided as a convenience and is re-used in case of a reinstall. On uninstall, Setup disables the account but does not delete it. The reason is that file permissions assigned will not resolve (they will appear as SIDs) if you delete the account. For this reason, deleting the account is not recommended.

  2. To remove the user profile, use the Windows steps. What I usually do is the following: a. Open a PowerShell window as administrator b. Enter the command SystemPropertiesAdvanced c. Click the Settings... button in the User Profiles section of the dialog d. Click the profile for the user in the list and click Delete

steroeck commented 5 months ago

After uninstalling Syncthing I had to restart Windows. Then the Delete button in the User Profiles dialog page for SyncthingServiceAcct was not greyed out anymore. Maybe deleting the profile this way I finally was able to delete the "/Users/SyncthingServiceAcct" folder with the windows file Explorer.