PDA

View Full Version : How can I delete folders and shortcuts from a users profile?



jazeboy1
03-10-2008, 12:44 AM
Hi I am trying to delete files and folders from a users desktop and start menu through installscript and custom action

I cannot get it to work.

I'm using:

function ExFn_RemoveFile(hMSI)
begin
//DeleteFile("C:\\Documents & Settings\\*\\Desktop\\orderprints*") ;
//DeleteDir( "C:\\Documents & Settings\\*\Start Menu\Programs\\Picture Organiser',ALLCONTENTS) ;
end;

Do I need to call a value for USERPROFILE instead of using this?

How can I get this to work? Thanks.

jazeboy1
03-10-2008, 12:53 AM
Note: I have removed the // when trying to test it

bryanwolf
03-10-2008, 10:07 AM
I'm not sure that DeleteFile supports wild card characters in the path provided. Have you determined what the return values from DeleteFile & DeleteDir are?

More specifically, based on the function prototype, this is a custom action. Is there a specific reason you're opting to not use the RemoveFile table? And possibly more specifically you can't guarantee that you've actually deleted the shortcuts. Typically, it's best to leave per-user data behind. You may want to install the shortcuts for all users if, in fact, your installation installs for all users. This way, Windows Installer will clean up your shortcuts for you and you won't have this problem.

These types of patterns usually fail on corporate systems and especially have issues with AD systems that use roaming profiles.

jazeboy1
03-10-2008, 07:35 PM
The problem is I'm cleaning up old installs I didn't create so have to try and clean up these shortcuts.

Thanks for advice on removefile table, i'll look into it.

How do I force it to install for all users??

bryanwolf
03-11-2008, 08:14 AM
You can do so by setting the ALLUSERS property:
http://msdn2.microsoft.com/en-us/library/aa367559(VS.85).aspx

By default it's done for you.