cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
peterbi
Level 7

How to solve All Users desktop loation on W2K and later?

Hi,

I am troubleshooting a shortcut problem, and want to delete a .lnk file from allusers desktop folder.

The location in W2K and XP is at C:\Documents and Settings\All Users\Desktop (I am assuming W2K3 will be the same), but on Vista, it's Desktop\Public\Public Desktop . I would like to call 'del' to delete the .lnk file during uninstall, how can I relsove (property/reg key/etc.) the location in my IS Script file?


Thanks,
Peter
Labels (1)
0 Kudos
(7) Replies
RobertDickau
Flexera Alumni

Assuming a per-machine installation, would FOLDER_DESKTOP or DesktopFolder have the value you want?
0 Kudos
peterbi
Level 7

Hi Robert,

Thank you for your reply.

Unfortunately neither of the properties you provided works for me. I insert a bunch of properties into my code and see what they return, and only 'StartupFolder' returned something, not exactly what I wanted though, I have to process it and make up a 'Desktop' folder. Here is the list I tried in my script (please note that I am using InstallScript MSI, not Basic MSI):

CSIDL_COMMON_DESKTOPDIRECTORY
FOLDERID_PublicDesktop
ALLUSERSPROFILE
FOLDER_COMMON_APPDATA
StartMenuFolder
StartupFolder
FOLDER_DESKTOP
DesktopFolder

Testing code is:
MsiGetProperty(ISMSI_HANDLE ,"CSIDL_COMMON_DESKTOPDIRECTORY",sDir,nvSize); MessageBox("CSIDL_COMMON_DESKTOPDIRECTORY is " + sDir, INFORMATION);
Another strange thing I found is that if I put another call of 'StartupFolder' after the first one, the second one returns nothing (empty). Is this normal? I am suprised though. I also noticed that I put the same code to other places, they show different results, eg. the above code in inside OnMaintUIBefore(), if I put the code in OnBegin(), 'StartupFolder' returned empty.

I emphasized it's IS MSI project because I didn't notice the strange behaviors on Basic MSI before.

P.S. Is there a MSI or IS property for "%systemfolder%\Documents and Settings" directory, maybe I can use it to build up my 'desktop' folder, since I feel 'StartupFolder' is not that stable.

Thanks,
Peter
0 Kudos
peterbi
Level 7

Forget to mention that I did set 'ALLUSERS' property to '1' in the project and my testing target systems include W2K/XP/W2K3, I need to handle Vista differently.

Here is the description about 'DesktopFolder' from IS2008:

DesktopFolder
This property is used to hold the full path to the Desktop folder for the current user. If the setup is being run under Windows NT 4 or Windows 2000 for All Users, and the ALLUSERS property is set, then the DesktopFolder property should hold the full path to the All Users desktop folder.
0 Kudos
RobertDickau
Flexera Alumni

In general, you'll want to set the buffer-size argument (nvSize in your example) to a large enough number to hold the returned value before calling MsiGetProperty. That is, add a line like this:

nvSize = MAX_PATH + 1;

before each call to MsiGetProperty.

Please see the MSI help and InstallShield help for explanations of those names you're using: FOLDER_DESKTOP and FOLDER_COMMON_APPDATA are InstallScript variables, which you can use directly without going through MsiGetProperty; while DesktopFolder, StartupFolder, and StartMenuFolder can be used in MsiGetProperty. (Some of them might also work as a raw variable in an InstallScript MSI project.) The CSIDL_ value is an argument to a Windows API function, so it presumably wouldn't work as a raw variable or in MsiGetProperty.
0 Kudos
peterbi
Level 7

Robert,

Thank you so much for your helpful suggestions, now the following properties work:

ALLUSERSPROFILE
StartMenuFolder
StartupFolder
DesktopFolder

That's good enough for me.

But I got error in DeleteFile() call, the file path passed in is correct and I also used LongPathToQuote(szFile,TRUE) before DeleteFile(szFile). FormatMessage(nErr) returns "The system cannot openthe file", but I can issue 'del' command and delete the file while the error message shows on. The file is a .lnk file for desktop shortcut (C:\Documents and Settings\All Users\Desktop\File Name.lnk), without removing the file, the shortcut icon is left on desktop after uninstallation.

I also checked that it's not 'read-only' at uninstallation.

Any suggestion on it?


Thanks,
Peter
0 Kudos
peterbi
Level 7

You can ignore it, but you are welcome to reply if you do have suggestion/solution.

I now make it work by puting entry in RemoveFile table. It worked on W2K, but I need to test it on Vista.


Thanks,
Peter
0 Kudos
peterbi
Level 7

It works on Vista, but not perfectly -

The icon actually is deleted but still visible on the desktop, reboot will clear it out from the desktop though. Without reboot, it even can't be deleted manually, I got 'Item Not Found' erorr with message "Could not find this itm - This is no longer located in C:\Users\Public\Public Desktop. Verify the item's location and try again" (see the attached screenshot). Once I restart the system, the icon is gone.

It will be perfect if the icon is gone from desktop after installation, anybody get any idea?


Thanks,
Peter
0 Kudos