If you've used Inno Setup to install a Windows service, you may have encountered the issue where the service's files are not deleted during uninstallation. This can be frustrating, especially if you need to free up space on your hard drive. In this article, we'll explain why this happens and show you how to delete the service's files manually.
Why aren't the service's files deleted during uninstallation?
When you uninstall a program using Inno Setup, it runs the uninstaller script that you've provided. This script is responsible for removing the files, registry keys, and other components that were installed by the setup program. However, if the uninstaller script doesn't include code to delete the service's files, they will be left behind after the uninstallation.
This is often the case with services that are installed to run under the Local System account. By default, the Local System account has full control over the entire system, including the program files directory. This means that the uninstaller script may not be able to delete the service's files, even if it tries to.
How to delete the service's files manually
To delete the service's files manually, you'll need to follow these steps:
- Stop the service: Before you can delete the service's files, you need to stop the service. You can do this using the
sc stopcommand in the Command Prompt. For example, if the service is called "MyService", you would enter the following command:
sc stop MyService
- Delete the service's files: Now that the service is stopped, you can delete its files. The location of the files depends on how you installed the service. If you used the
[Files]section in your Inno Setup script, the files will be located in the directory that you specified. If you used the[Run]section to install the service, the files will be located in the directory that the[Run]section specifies.
To delete the files, you can use the del command in the Command Prompt. For example, if the service's files are located in the C:\Program Files\MyService directory, you would enter the following command:
del /S /Q "C:\Program Files\MyService\*"
This command will delete all the files and subdirectories in the MyService directory.
- Delete the service: Now that the service's files have been deleted, you can delete the service itself. You can do this using the
sc deletecommand in the Command Prompt. For example, if the service is called "MyService", you would enter the following command:
sc delete MyService
If the uninstaller script doesn't include code to delete the service's files, they will be left behind after the uninstallation. To delete the service's files manually, you need to stop the service, delete the service's files using the del command in the Command Prompt, and then delete the service itself using the sc delete command.
References
| Title | Author | Publication | Date |
|---|---|---|---|
| Files Section | Jordan Russell | Inno Setup Help | 2023 |
| sc stop | Microsoft | Windows Server Docs | 2023 |
| del | Microsoft | Windows Server Docs | 2023 |
| sc delete | Microsoft | Windows Server Docs | 2023 |