Checked again with the "echo" line in the batch file.
So, I used the following code (so, the log files should be actually removed several times):
// Add operations to installing/uninstalling
Component.prototype.createOperations = function()
{
// Use standard operations as well
component.createOperations();
// In case of uninstaller, clean up log file directory before removing it
if(installer.isUninstaller())
{
if(systemInfo.productType == "windows")
{
component.addOperation("Execute", "erase /s /f /q", Dir.toNativeSparator(installer.value("logFilePath") + "\\*.*"));
}
component.addOperation("Execute", "cmd", ["/C", "@TargetDir@\removeLogs.bat"]);
}
if(installer.isInstaller())
{
installer.execute("cmd", ["/C", "mkdir", logFilePath]);
}
if(installer.isUninstaller())
{
installer.execute("cmd", ["/C", "@TargetDir@\removeLogs.bat"]);
}
// Create batch file for removing log files by uninstaller
component.addOperation("AppendFile" , "@TargetDir@/removeLogs.bat", "echo \"Executed\" >> C:\\_data\\test.txt\ndel /q " + installer.value("logFilePath") + "\\*.*");
}
The batch file was correctly created in the target dir, containing
echo "Executed" >> C:\_data\test.txt
del /q C:\_data\test\logs\*.*
However, the files were not deleted by the uninstaller, nor was C:_data\test.txt written.
Before uninstallation, I copied the batch file also to C:_data. After uninstallation, I simply executed the batch file by double-clicking on it from the Win explorer and both the files were successfully deleted as well as C:_data\test.txt written.
Did I maybe simply overlook something?
Or maybe this simply doesn't work in the createOperations function?
Kind regards,
Markus