cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jazeboy1
Level 3

How can I delete folders and shortcuts from a users profile?

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.
Labels (1)
0 Kudos
(4) Replies
jazeboy1
Level 3

Note: I have removed the // when trying to test it
0 Kudos
Not applicable

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.
0 Kudos
jazeboy1
Level 3

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??
0 Kudos
Not applicable

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.
0 Kudos