Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

MsiSetTargetPath function

The MsiSetTargetPath function sets the full target path for a folder in the Directory table.


UINT MsiSetTargetPath(
  _In_ MSIHANDLE hInstall,
  _In_ LPCTSTR   szFolder,
  _In_ LPCTSTR   szFolderPath


hInstall [in]

Handle to the installation provided to a DLL custom action or obtained through MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct.

szFolder [in]

Specifies the folder identifier. This is a primary key in the Directory table.

szFolderPath [in]

Specifies the full path for the folder, ending in a directory separator.

Return value

The MsiSetTargetPath function returns the following values:


The directory specified was not found in the Directory table.


An invalid or inactive handle was supplied.


An invalid parameter was passed to the function.


The function succeeded.


The MsiSetTargetPath function changes the path specification for the target directory named in the in-memory Directory table. Also, the path specifications of all other path objects in the table that are either subordinate or equivalent to the changed path are updated to reflect the change. The properties for each affected path are also updated.

MsiSetTargetPath fails if the selected directory is read only.

If an error occurs in this function, all updated paths and properties revert to their previous values. Therefore, it is safe to treat errors returned by this function as nonfatal.

Do not attempt to configure the target path if the components using those paths are already installed for the current user or for a different user. Check the ProductState property before calling MsiSetTargetPath to determine if the product containing this component is installed.

See Calling Database Functions From Programs.

If the function fails, you can obtain extended error information by using MsiGetLastErrorRecord.



Windows Installer 5.0 on Windows Server 2012, Windows 8, Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003 or Windows XP







Unicode and ANSI names

MsiSetTargetPathW (Unicode) and MsiSetTargetPathA (ANSI)

See also

Installer Location Functions



Community Additions

© 2015 Microsoft