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
- :
- InstallShield
- :
- InstallShield Forum
- :
- Finding %userprofile% folder
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
‎Apr 22, 2008
01:14 PM
Finding %userprofile% folder
Hello, I am working on an InstallScript project, where I want to be able to remove a specific folder (if it exists) under a User's local home folder (on Vista systems). For example, if the folder C:\Users\\AppData\Local\VirtualStore\ exists, I want to be able to delete it. Is there some kind of command in InstallScript similar to %userprofile% that easily finds the User's local home folder? Any help would be greatly appreciated. Thanks.
Regards,
Randy
Regards,
Randy
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 22, 2008
01:32 PM
I am not sure about the virtual store but the following helps us to find the ALLUSERS directory.
Here is the header info:
[code]
#ifndef CSIDL_COMMON_DOCUMENTS
#define CSIDL_COMMON_DOCUMENTS 0x002e // All Users\Documents
#endif
export prototype SetCommonDocumentsDir(HWND);
prototype NUMBER SHFolder.SHGetFolderPathA(HWND, //A handle to an owner window. This parameter is typically set to NULL
NUMBER, //A CSIDL value that identifies the folder whose path is to be retrieved.
NUMBER, //[in] An access token that can be used to represent a particular user.
NUMBER, //[in] The flags to specify which path is to be returned.
//It is used for cases where the folder associated with a CSIDL
//may be moved or renamed by the user.
//SHGFP_TYPE_CURRENT
// Return the folder's current path.
//SHGFP_TYPE_DEFAULT
// Return the folder's default path.
BYREF STRING);//[out] A pointer to a null-terminated string of length
//MAX_PATH which will receive the path. If an error occurs or S_FALSE
//is returned, this string will be empty.
[/code]
I am sure you can find the appropriate CSIDL value by searching MSDN for what you are looking for.
function SetCommonDocumentsDir (hMSI)
NUMBER nResult;
STRING strCommonDocumentsDir;
begin
nResult = SHFolder.SHGetFolderPathA(NULL, CSIDL_COMMON_DOCUMENTS, NULL, 0, strCommonDocumentsDir);
if nResult =0
then
MsiSetProperty(hMSI, "COMMONDOCUMENTS", strCommonDocumentsDir);
else
SprintfMsiLog("Failed to set path for COMMONDOCUMENTS. Return Value: %d", nResult);
endif;
end;
Here is the header info:
[code]
#ifndef CSIDL_COMMON_DOCUMENTS
#define CSIDL_COMMON_DOCUMENTS 0x002e // All Users\Documents
#endif
export prototype SetCommonDocumentsDir(HWND);
prototype NUMBER SHFolder.SHGetFolderPathA(HWND, //A handle to an owner window. This parameter is typically set to NULL
NUMBER, //A CSIDL value that identifies the folder whose path is to be retrieved.
NUMBER, //[in] An access token that can be used to represent a particular user.
NUMBER, //[in] The flags to specify which path is to be returned.
//It is used for cases where the folder associated with a CSIDL
//may be moved or renamed by the user.
//SHGFP_TYPE_CURRENT
// Return the folder's current path.
//SHGFP_TYPE_DEFAULT
// Return the folder's default path.
BYREF STRING);//[out] A pointer to a null-terminated string of length
//MAX_PATH which will receive the path. If an error occurs or S_FALSE
//is returned, this string will be empty.
[/code]
I am sure you can find the appropriate CSIDL value by searching MSDN for what you are looking for.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 22, 2008
01:38 PM
This is perfect Dan, many thanks for your quick reply! And yes, I can likely find the CSIDL through MSDN. Cheers.
Randy
Randy
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 22, 2008
03:50 PM
Hello, for anyone that might catch this thread and is looking for other CSIDL values (and for those who don't know what a CSIDL is, basically it is a value that provides a way to identify folders [used frequently by apps] which can have different names on different systems), click here for a list on MDSN:
http://msdn2.microsoft.com/en-us/library/bb762494.aspx
Thanks again to Dan for his help.
Regards,
Randy
http://msdn2.microsoft.com/en-us/library/bb762494.aspx
Thanks again to Dan for his help.
Regards,
Randy
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)