Custom action to delete a file - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Custom action to delete a file

Using AI 7.7:
I have one custom action, and after that custom action is executed, I want another SIMPLE (== one line) custom action that will delete a file.
I've read: http://www.advancedinstaller.com/user-g ... ialog.html
but it's not what I want (because I want to delete this file after my custom action and not before).
Just something simple.
So I have one custom action, and the second one after it is a custom action which deletes a file.
I've tried:
del <name of file>
and other variations of cmd.exe /K del <name of file>
but although cmd.exe worked! it left the "command prompt window" open, and until I don't close it the installer is waiting.

Dashut.
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Custom action to delete a file

Hi,

This can be done very easy, here is how:
-- first create a bat file with this content:

Code: Select all

del %1
-- add it as a temporary file in the project
-- now add a custom action "Launch File or Open URL"
-- set its Command Line field to the reference of the bat file and then the reference of the file you wish to delete, with a space between them

The reference of the second file will be resolved and passed as a parameter to the bat file which will delete it.

The custom action should be set to run as "Synchronous execution, ignore return code", "Deferred with no impersonation" and condition "NOT Installed".

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: Custom action to delete a file

Actually my problem is: I don't want to add temporary files: because this doesn't work for me as mentioned in post:
http://www.advancedinstaller.com/forums ... =2&t=11393

Anyway, I created a simple C# program that deletes the file, but I would have been happier if I had this option as a custom action: just like "CreateExeProcess" done by you guys in: <AI_CUSTACTS>aicustact.dll (there are some delete functions there: but not "DeleteFile" for example...)

Dashut.

Return to “Common Problems”