This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Re: how to delete some folders using custom code
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 14, 2008
09:07 AM
how to delete some folders using custom code
hi,
i want to delete some folders in the $USER_INSTALL_DIR$ using custom code in the install task or post install task .
Can anyone provide some suggestion and some sample code for deleting the folders in the $USER_INSTALL_DIR$ say FIRST FOLDER ,SECOND FOLDER in the install task or in the post install task by executing custom code to achieve this.
i want to delete some folders in the $USER_INSTALL_DIR$ using custom code in the install task or post install task .
Can anyone provide some suggestion and some sample code for deleting the folders in the $USER_INSTALL_DIR$ say FIRST FOLDER ,SECOND FOLDER in the install task or in the post install task by executing custom code to achieve this.
(14) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 14, 2008
10:43 AM
I'm not sure why you would need custom code in order to delete folders, you've got built-in actions for that.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 16, 2008
05:03 AM
hi,
i would like to know where i will be able to find the delete file\folder action in the post install task.
And say i want to write custom code for achieving this,isnt it possible to delete a folder in the post install task using custom code action
AND if possible it would be a pleasure to get sample code for doing this.
i would like to know where i will be able to find the delete file\folder action in the post install task.
And say i want to write custom code for achieving this,isnt it possible to delete a folder in the post install task using custom code action
AND if possible it would be a pleasure to get sample code for doing this.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 16, 2008
05:28 AM
If the delete file/folder is not available in the post-install task, then why can't you use in the install task (see your initial question). What is your IA version?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 18, 2008
04:34 AM
hi,
can i get some custom code action for deleting folders .
Hi i want to delete some folders which get cached(say) after installation
.Can anyone provide some sample custom code action for deleting folder.
Regards,
James
can i get some custom code action for deleting folders .
Hi i want to delete some folders which get cached(say) after installation
.Can anyone provide some sample custom code action for deleting folder.
Regards,
James
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 18, 2008
08:54 AM
A Google search will find an example for deleting a directory.
Here's one result...
http://www.exampledepot.com/egs/java.io/DeleteDir.html
Here's one result...
http://www.exampledepot.com/egs/java.io/DeleteDir.html
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 18, 2008
09:15 AM
James, why would you like to complexify your tasks whenever there are easier workarounds. Ok, so the Delete Files / Folders actions are not available in Post-Install task, but Execute Commands are too! So instead of writing custom code, what prevents you from executing commands like:
CMD /C DEL /F /Q "$TEMP_DIR$ (for Windows) or
sh -c "rm -rf $TEMP_DIR$" for Unices.
Ok, I don't deny, writing custom code would mean that you always execute the same code on any of your platforms, but compare these one-liners with the task of writing, testing and integrating the custom code.
CMD /C DEL /F /Q "$TEMP_DIR$ (for Windows) or
sh -c "rm -rf $TEMP_DIR$" for Unices.
Ok, I don't deny, writing custom code would mean that you always execute the same code on any of your platforms, but compare these one-liners with the task of writing, testing and integrating the custom code.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 21, 2008
08:34 AM
public void uninstall(UninstallerProxy arg0) throws InstallException
{
try
{
uninstallDir = "Uninstall";
String buttonValue=arg0.substitute("$CHOSEN_DIALOG_BUTTON$");
System.out.println("button value is --- "+buttonValue);
if(0==Integer.parseInt(buttonValue))
deleteDirectory(arg0.substitute("$USER_INSTALL_DIR$"));
else
deleteDirectory(new File(arg0.substitute("$USER_INSTALL_DIR$")));
productName = arg0.substitute("$PRODUCT_NAME$");
System.out.println("product name is -----" + productName);
File file = new File(arg0.substitute("$USER_INSTALL_DIR$"));
//if (file.isDirectory() && file.list().length > 0)
file.deleteOnExit();
}
catch (Exception ioe)
{
System.out.println(ioe.getMessage());
}
}
/**
* Delete the specified directory represented by directoryToDelete.
* If the directory is not empty, its contents are deleted recursively
* before it is removed.
*/
public void deleteDirectory(String directoryToDelete) throws IOException
{
// fis = new FileOutputStream(f);
try
{
searchDirectory(new File(directoryToDelete));
}
finally
{
// fis.close();
}
}
/**
* Delete the specified directory represented by directoryToDelete.
* If the directory is not empty, its contents are deleted recursively
* before it is removed.
*/
public void searchDirectory(File directoryToDelete) throws IOException
{
// make sure it's a directory
if (directoryToDelete.isDirectory())
{
String fileSep = System.getProperty("file.separator");
String[] filesAndDirs = directoryToDelete.list();
int numberOfFiles = filesAndDirs.length;
if (directoryToDelete.getName().equals("lib"))
{
deleteDirectory(directoryToDelete);
}
for (int i = 0; i < numberOfFiles; i++)
{
File currentFile = new File(directoryToDelete.getPath() + fileSep + filesAndDirs);
if (currentFile.isDirectory())
searchDirectory(currentFile);
}
}
else
{
System.err.println("Couldn't delete directory because directory is a file : " +
directoryToDelete.getAbsolutePath());
throw new IOException("Couldn't delete directory because directory is a file : " +
directoryToDelete.getAbsolutePath());
}
}
public void deleteDirectory(File directoryToDelete)
{
String fileSep = System.getProperty("file.separator");
String[] filesAndDirs = directoryToDelete.list();
int numberOfFiles = filesAndDirs.length;
for (int i = 0; i < numberOfFiles; i++)
{
File currentFile = new File(directoryToDelete.getPath() + fileSep + filesAndDirs);
if (currentFile.isDirectory())
{
if(currentFile.getName().equals("CamapignExecutorUninstall"))
continue;
System.out.println(currentFile + " is a folder so browse it.");
deleteDirectory(currentFile);
}
else
{
System.out.println("deleting file ... : " + currentFile.getName());
currentFile.delete();
}
}
System.out.println("###################### Deleting the " + directoryToDelete + " now. ##############################");
directoryToDelete.delete();
}
{
try
{
uninstallDir = "Uninstall";
String buttonValue=arg0.substitute("$CHOSEN_DIALOG_BUTTON$");
System.out.println("button value is --- "+buttonValue);
if(0==Integer.parseInt(buttonValue))
deleteDirectory(arg0.substitute("$USER_INSTALL_DIR$"));
else
deleteDirectory(new File(arg0.substitute("$USER_INSTALL_DIR$")));
productName = arg0.substitute("$PRODUCT_NAME$");
System.out.println("product name is -----" + productName);
File file = new File(arg0.substitute("$USER_INSTALL_DIR$"));
//if (file.isDirectory() && file.list().length > 0)
file.deleteOnExit();
}
catch (Exception ioe)
{
System.out.println(ioe.getMessage());
}
}
/**
* Delete the specified directory represented by directoryToDelete.
* If the directory is not empty, its contents are deleted recursively
* before it is removed.
*/
public void deleteDirectory(String directoryToDelete) throws IOException
{
// fis = new FileOutputStream(f);
try
{
searchDirectory(new File(directoryToDelete));
}
finally
{
// fis.close();
}
}
/**
* Delete the specified directory represented by directoryToDelete.
* If the directory is not empty, its contents are deleted recursively
* before it is removed.
*/
public void searchDirectory(File directoryToDelete) throws IOException
{
// make sure it's a directory
if (directoryToDelete.isDirectory())
{
String fileSep = System.getProperty("file.separator");
String[] filesAndDirs = directoryToDelete.list();
int numberOfFiles = filesAndDirs.length;
if (directoryToDelete.getName().equals("lib"))
{
deleteDirectory(directoryToDelete);
}
for (int i = 0; i < numberOfFiles; i++)
{
File currentFile = new File(directoryToDelete.getPath() + fileSep + filesAndDirs);
if (currentFile.isDirectory())
searchDirectory(currentFile);
}
}
else
{
System.err.println("Couldn't delete directory because directory is a file : " +
directoryToDelete.getAbsolutePath());
throw new IOException("Couldn't delete directory because directory is a file : " +
directoryToDelete.getAbsolutePath());
}
}
public void deleteDirectory(File directoryToDelete)
{
String fileSep = System.getProperty("file.separator");
String[] filesAndDirs = directoryToDelete.list();
int numberOfFiles = filesAndDirs.length;
for (int i = 0; i < numberOfFiles; i++)
{
File currentFile = new File(directoryToDelete.getPath() + fileSep + filesAndDirs);
if (currentFile.isDirectory())
{
if(currentFile.getName().equals("CamapignExecutorUninstall"))
continue;
System.out.println(currentFile + " is a folder so browse it.");
deleteDirectory(currentFile);
}
else
{
System.out.println("deleting file ... : " + currentFile.getName());
currentFile.delete();
}
}
System.out.println("###################### Deleting the " + directoryToDelete + " now. ##############################");
directoryToDelete.delete();
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 22, 2008
04:42 AM
hi,
if i use this command that is CMD /C DEL /F /Q "$TEMP_DIR$
will it delete the $TEMP_DIR$ of windows
if i use this command that is CMD /C DEL /F /Q "$TEMP_DIR$
will it delete the $TEMP_DIR$ of windows
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 22, 2008
07:36 AM
Quoting from the manual:
"Temp Directory $TEMP_DIR$ This variable represents the temp directory on the target machine. When running the pure Java installer on Windows, $TEMP_DIR$ will resolve the user's home directory."
It's usually something like C:\Documents and Settings\UserName\Local Settings\Temp
But please bear in mind the fact that what I gave you was an example (and a stripped one (i.e. I've remove the extra folder that was in the temp folder) that I'm not sure it'll work as is, and that because usually there are other applications using the temp folder, so attempting to directly delete this folder will fail, as certainly there will be other files locked in that folder.
"Temp Directory $TEMP_DIR$ This variable represents the temp directory on the target machine. When running the pure Java installer on Windows, $TEMP_DIR$ will resolve the user's home directory."
It's usually something like C:\Documents and Settings\UserName\Local Settings\Temp
But please bear in mind the fact that what I gave you was an example (and a stripped one (i.e. I've remove the extra folder that was in the temp folder) that I'm not sure it'll work as is, and that because usually there are other applications using the temp folder, so attempting to directly delete this folder will fail, as certainly there will be other files locked in that folder.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 22, 2008
08:53 AM
I forgot that there was a ready made custom code for you: http://www.zerog.com/extensions/DeleteDirectory.zip
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 20, 2008
08:02 AM
I am extracting a tomcat.zip during the installation into the $USER_INSTALL_DIR$.
during the Uninstallation , the tomcat folder is not deleted, bcoz it has new log files created.... how to delete this..
There is NO option for FORCED delete(Recursively delete) for extracting files.
during the Uninstallation , the tomcat folder is not deleted, bcoz it has new log files created.... how to delete this..
There is NO option for FORCED delete(Recursively delete) for extracting files.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 20, 2008
08:49 AM
any solution?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 20, 2008
09:51 AM
Create the directory first, then extract the zip. Then you can have the "Recursiveley delete all contents of this folder during uninstall" checkbox checked.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 28, 2009
12:13 PM
Have you tried the Execute Script/Batch File action? You can write the operating system native script (Unix shell and Windows .bat) in that action to do pretty much everything. Also you can use the IA variables in the script that give you more control.