Remove a not-empty folder, a classic question
Hello !
I install a package which include a program which create a folder and add in it some files.
I know how to delete these files, even if I don't know their name, but I don't succeed in removing the folder. It appears that (as said in the msdn) the folder is removed only if empty.
So 2 questions :
How could I delete a folder (empty or not) ? (using "pure" msi)
or How could I sequence the removing process in order to delete the folder once it is empty ?
Thx !
I install a package which include a program which create a folder and add in it some files.
I know how to delete these files, even if I don't know their name, but I don't succeed in removing the folder. It appears that (as said in the msdn) the folder is removed only if empty.
So 2 questions :
How could I delete a folder (empty or not) ? (using "pure" msi)
or How could I sequence the removing process in order to delete the folder once it is empty ?
Thx !
0 Comments
[ + ] Show comments
Answers (16)
Please log in to answer
Posted by:
WiseUser
19 years ago
Posted by:
babric
19 years ago
By "pure msi" I mean "without using some vbscript" :-)
WiseUser : Sure I tried the Remove table as follow :
FileKey Component FileName DirProperty InstallMode
All NewComponent1 * INSTALLDIR 2
Folder NewComponent2 INSTALLDIR 2
INSTALLDIR is a path to a test Folder I created before (e:\TEST)
This doesn't seem to work...
Did I miss something ?
WiseUser : Sure I tried the Remove table as follow :
FileKey Component FileName DirProperty InstallMode
All NewComponent1 * INSTALLDIR 2
Folder NewComponent2 INSTALLDIR 2
INSTALLDIR is a path to a test Folder I created before (e:\TEST)
This doesn't seem to work...
Did I miss something ?
Posted by:
WiseUser
19 years ago
I can't read your post very easily, but it seems to look alright to me?
Does "E:\Test\" have any subfolders? Is it empty after you remove the MSI?
Make sure that "NewComponent1" and "NewComponent2" don't have the "msidbComponentAttributesPermanent" or "msidbComponentAttributesSharedDllRefCount" attributes set. Also check that they're actually installed in the first place.
If you find that they did have these attributes set, try changing their component codes.
Have you tried hard-coding "ROOTDRIVE=E:\"?
Does "E:\Test\" have any subfolders? Is it empty after you remove the MSI?
Make sure that "NewComponent1" and "NewComponent2" don't have the "msidbComponentAttributesPermanent" or "msidbComponentAttributesSharedDllRefCount" attributes set. Also check that they're actually installed in the first place.
If you find that they did have these attributes set, try changing their component codes.
Have you tried hard-coding "ROOTDRIVE=E:\"?
Posted by:
babric
19 years ago
I had hardcoded INSTALLDIR as e:\test\
But I just tried something else :
I hardcoded the INSTALLDIR2 Property and set it to e:\test\smthg
And then, use this property in my removeFile table.
And... it works [8|].
I don't understand why, but that's good :-)
Note : The shared bit is set, and it doesn't change anything here (I don't use .dll in these folders)
Thank you ![:D]
But I just tried something else :
I hardcoded the INSTALLDIR2 Property and set it to e:\test\smthg
And then, use this property in my removeFile table.
And... it works [8|].
I don't understand why, but that's good :-)
Note : The shared bit is set, and it doesn't change anything here (I don't use .dll in these folders)
Thank you ![:D]
Posted by:
viv_bhatt1
19 years ago
Following cases should be considered :
1) If your application is creating new folders / subfolders at runtime , then Removefiletable will not be of much help . You have to use custom action , I am not aware of any pure msi way of achieving that
2) If your application is creating only files at runtime then giving wildcard (*) will remove everything
3) If you application is leaving a blank folder then removefiletable will take care of removal
All cases discussed above can take following values :
File Key
Remove_[DirectoryName]
Component
[ComponentName]
FileName
*
Dirproperty
[DIRPROPERTY]
InstallMode
3
Cheers ,
V
1) If your application is creating new folders / subfolders at runtime , then Removefiletable will not be of much help . You have to use custom action , I am not aware of any pure msi way of achieving that
2) If your application is creating only files at runtime then giving wildcard (*) will remove everything
3) If you application is leaving a blank folder then removefiletable will take care of removal
All cases discussed above can take following values :
File Key
Remove_[DirectoryName]
Component
[ComponentName]
FileName
*
Dirproperty
[DIRPROPERTY]
InstallMode
3
Cheers ,
V
Posted by:
WiseUser
19 years ago
Posted by:
babric
19 years ago
1) If your application is creating new folders / subfolders at runtime , then Removefiletable will not be of much help . You have to use custom action , I am not aware of any pure msi way of achieving that
I tried the following sequence :
1*/Execute msi : it creates a new folder e:\TEST\
2*/Create manually a new Folder e:\TEST\SMTGH
3*/Copy some files in this folder (manually)
4*/Execute msi : ALL is removed (e:\TEST no more exists)
Of course, if I create a new subfolder under e:\TEST\SMTGH\, it won't be removed... (But I should not meet this case)
So I don't understand your answer : If I know the folder which could be created, I can do it without using some vbs ? no ?
Posted by:
WiseUser
19 years ago
Of course.
Best practice would suggest that you include any files and folders that you know about in your package.
As software repackagers we can't always anticipate every file or folder which might be created - unless we are working in a tightly "locked-down" environment of course.
But a little bird tells me that you're not a "repackager"? If it's your own application you should know which files or folders might be created.
Best practice would suggest that you include any files and folders that you know about in your package.
As software repackagers we can't always anticipate every file or folder which might be created - unless we are working in a tightly "locked-down" environment of course.
But a little bird tells me that you're not a "repackager"? If it's your own application you should know which files or folders might be created.
Posted by:
babric
19 years ago
Posted by:
viv_bhatt1
19 years ago
Yes you are right, I have to agree with you . As long as you know which folders your application is going to create at runtime and you can mention them in removefile table everything will work fine .
I am talking about the case where you do not know which folder your application will create at runtime . For eg:-
Application creates a new folder within e:\test\SMTGH , which is created for every new user logged on to the machine and contains the logged on users login name (A lot of CA applications do that). In this case we can't find the name of folders created by the application . Hence Removefile table entry will not work and will leave all the new folders /subfolders not covered in your package .
Again Remove file table will work in case as mentioned by you where you aren't expecting any new subfolders to be created by your application apart from the one mentioned in your msi .
Hope this helps .
Cheers ,
V
I am talking about the case where you do not know which folder your application will create at runtime . For eg:-
Application creates a new folder within e:\test\SMTGH , which is created for every new user logged on to the machine and contains the logged on users login name (A lot of CA applications do that). In this case we can't find the name of folders created by the application . Hence Removefile table entry will not work and will leave all the new folders /subfolders not covered in your package .
Again Remove file table will work in case as mentioned by you where you aren't expecting any new subfolders to be created by your application apart from the one mentioned in your msi .
Hope this helps .
Cheers ,
V
Posted by:
viv_bhatt1
19 years ago
Are you expecting a reply for shared dll's ? I am not sure where did I mention Shared dll . I have checked it twice , please let me know .
ORIGINAL: babric
Yes, SharedDll is really a confusing name...
Of course
maybe viv_bhatt1 know something we don't know :-/
I don't really understand his sentence so I'll wait for his answer.
Posted by:
babric
19 years ago
No no no no. We have all quickly answered so it could be confusing :-)
I was talking about :
but you now have answered.
Topic closed ! :-)
I was talking about :
1) If your application is creating new folders / subfolders at runtime , then Removefiletable will not be of much help . You have to use custom action , I am not aware of any pure msi way of achieving that
but you now have answered.
Topic closed ! :-)
Posted by:
viv_bhatt1
19 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.