MsiSetTargetPath does not work - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

vicky
Posts: 66
Joined: Thu Aug 21, 2008 10:52 am

MsiSetTargetPath does not work

Hi!

I am using Advance Installer version 6.4.1 and building an enterprise project. I have attached a custom action to reset the target dir on "InstallInitialize", i calling: MsiSetTargetPath(hModule,"TARGETDIR", strTargetDir);
but, this function returns ERROR_DIRECTORY, I checked and confirmed that strTargetDir exists at my desired location, but, it is unable to set "TARGETDIR". My operating system is Win-xp with service pack2.

my verbose log shows following lines:

MSI (s) (74!4C) [16:43:11:396]: PROPERTY CHANGE: Modifying Initialising_VB_JAVA_Application_DIR property. Its current value is 'C:\Program Files\xxxxx\xxxxx\........'. Its new value: 'D:\Program Files\xxxxx\xxxxx\........'.

MSI (s) (74!4C) [16:43:11:474]: Note: 1: 2327 2: 32 3: D:\\Program Files\xxxxx\xxxxx\........

MSI (s) (74!4C) [16:43:11:474]: PROPERTY CHANGE: Modifying TARGETDIR property. Its current value is 'D:\Program Files\xxxxx\'. Its new value: 'C:\Program Files\xxxxxx\'.

MSI (s) (74!4C) [16:43:11:474]: PROPERTY CHANGE: Modifying APPDIR property. Its current value is 'D:\Program Files\xxxxx\'. Its new value: 'C:\Program Files\xxxxx\'.


Thanks in advance for your help.

Regards,
Vicky
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: MsiSetTargetPath does not work

Hi,

Please note that Advanced Installer uses APPDIR for the application folder, not TARGETDIR. Try using the APPDIR property and let me know if the problem persists.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vicky
Posts: 66
Joined: Thu Aug 21, 2008 10:52 am

Re: MsiSetTargetPath does not work

Hi Cosmin!

Thanks for ur quick reply, i tried MsiSetTargetPath(hModule,"APPDIR", strTargetDir); and the problem still persists i.e. MsiSetTargetPath returns "ERROR_DIRECTORY".

I've send u verbose log in my previous posting, was that helpful??

Regards,
Vicky
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: MsiSetTargetPath does not work

Hi Vicky,

ERROR_DIRECTORY is returned if the folder for which you need to set the path doesn't exist in the MSI package. Since APPDIR always exists in the MSI, perhaps your custom action doesn't use a correct handle to the install process. Please note that the User Guide contains a DLL custom action example which may help you.

Also, if you are using a C++ DLL, the MsiSetTargetPath call should look like this:

Code: Select all

::MsiSetTargetPath(hInstall, _T("APPDIR"), strTargetDir)
and strTargetDir should be set like this:

Code: Select all

TCHAR * strTargetDir = _T("C:\\MyFolder\\")
Please note that this function may also fail if the folder you set as the installation directory is read-only or the install process doesn't have enough privileges to write in it.
I've send u verbose log in my previous posting, was that helpful??
An installation log is not very helpful because the problem is caused by the custom action, not by the installation. Please note that what happens inside the custom action is not logged by Windows Installer.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vicky
Posts: 66
Joined: Thu Aug 21, 2008 10:52 am

Re: MsiSetTargetPath does not work

Hi!

Now, I am using following code to set Target Path:
int ret = MsiSetTargetPath(hModule, _T("APPDIR"), _T(strTargetDir.GetBuffer(strTargetDir.GetLength())));
so far in my knowledge GetBuffer() returns *TCHAR, so above code should work but it didn't.

It still returns ERROR_DIRECTORY. I am calling my custom DLL function on 'InstallInitialize' action. and am using AI 6.4.1.

I've verified "strTargetDir", it is existing .
One thing more, it happens only on two systems, on other systems MSi is working fine. There is no issue regarding permission cause i've logged in as Administrator and have enough privileges to read and write.

What could be the problem? I am unable to figure it out.

Regards,
Vicky
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: MsiSetTargetPath does not work

Hi Vicky,
it happens only on two systems, on other systems MSi is working fine.
Perhaps the problem is caused by these systems and not by the custom action. Can you please give me more details about them? What makes them different from the systems on which the custom action works?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vicky
Posts: 66
Joined: Thu Aug 21, 2008 10:52 am

Re: MsiSetTargetPath does not work

Hi Cosmin!

I've checked both the systems but didn't find any problem, all the systems have Windows-XP with SP2, we are also able to install other softwares. User has enough rights to read/write in the target dir.

Please analyze the following log traces, i've added comments to it:

//I am going to change the target dir
MSI (s) (1C:F4) [10:31:56:312]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI11.tmp, Entrypoint: ResetTargetPath

//property has changed successfully
MSI (s) (1C!E0) [10:32:06:500]: PROPERTY CHANGE: Modifying APPDIR property. Its current value is 'C:\Program Files\Databorough\'. Its new value: 'D:\Program Files\Databorough\'.

//Path has been updated
MSI (s) (1C!E0) [10:32:16:765]: PROPERTY CHANGE: Modifying org.eclipse.core.resources_DIR property. Its current value is 'C:\Program Files\Databorough\X-Browse\x-app\workspace\.metadata\.plugins\org.eclipse.core.resources\'. Its new value: 'D:\Program Files\Databorough\X-Browse\x-app\workspace\.metadata\.plugins\org.eclipse.core.resources\'.

//Some error has occurred
MSI (s) (1C!E0) [10:32:16:843]: Note: 1: 2327 2: 32 3: D:\Program Files\Databorough\X-Browse\

//Target dir changed to default
MSI (s) (1C!E0) [10:32:16:843]: PROPERTY CHANGE: Modifying APPDIR property. Its current value is 'D:\Program Files\Databorough\'. Its new value: 'C:\Program Files\Databorough\'.

What is the significance of "2327"? after going through some articles it stands for "Can not remove Directory."

Could you please explain it? So, that i can dig further.
Thanks for giving your valuable time.

Regards,
Vicky
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: MsiSetTargetPath does not work

Hi Vicky,

The error code 2327 does mean "Could not remove directory", but I'm not sure why this happens. Does your custom action uses code which removes a folder? If not, please send us the AIP you are using and the complete log to support at advancedinstaller dot com so we can investigate them.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vicky
Posts: 66
Joined: Thu Aug 21, 2008 10:52 am

Re: MsiSetTargetPath does not work

Hi Cosmin!

I have send you .aip and .log file at support e-mail address.
please find the mail.

Regards,
Vicky
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: MsiSetTargetPath does not work

Hi Vicky,

We did not receive any emails from you. Can you please send it again? The email address is support at advancedinstaller dot com (replace " at " with "@" and " dot " with ".").

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vicky
Posts: 66
Joined: Thu Aug 21, 2008 10:52 am

Re: MsiSetTargetPath does not work

Hi Cosmin!

I have send you the mail again.

Regards,
Vicky
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Re: MsiSetTargetPath does not work

Hi Vicky,

I have built the AIP file you have sent using dummy files and used the following code for the "ResetTargetPath" function, but I could not reproduce the problem you are encountering:

Code: Select all

UINT __stdcall ResetTargetPath(MSIHANDLE hInstall)
{
  TCHAR szFolder[MAX_PATH] = _T("APPDIR");
  TCHAR szFolderPath[MAX_PATH] = _T("D:\\Program Files\\Databorough");
  TCHAR szBuffer[MAX_PATH] = { 0 };
  
  //DebugBreak();
  UINT res = ::MsiSetTargetPath(hInstall, szFolder, szFolderPath);
  wsprintf(szBuffer, _T("MsiSetTargetPath returned: %lu"), res);

  ::MessageBox(::GetForegroundWindow(), szBuffer, _T("Info"), MB_ICONINFORMATION);

  return ERROR_SUCCESS;
}
As a note, you are not required to write your own Custom Action in order to change the target location for a directory. You can simply use a "Directory Set with Formatted" Custom Action which uses MsiSetTargetPath internally.

Regarding the following note in the log file:

Code: Select all

Note: 1: 2327 2: 32 3: D:\Program Files\Databorough\eclipse\

the error code 2327 means indeed:

Code: Select all

Could not remove directory: [3] GetLastError: [2].

with the values of the fields being in this case:

Code: Select all

[3] = D:\Program Files\Databorough\eclipse\
[2] = 32
The error code "32" returned by GetLastError means:

Code: Select all

The process cannot access the file because it is being used by another process.
Hence, check to make sure if the above folder exists before the installation and whether there are processes that have handles open to it. For this purpose, you can use the free tool Process Explorer which can be downloaded from this page. Before the installation, use the option "Find Handle or DLL" and search for the string "eclipse", "Databorough" or the whole path of the above directory.

Hope this helps.

Regards,
Ionut
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/
vicky
Posts: 66
Joined: Thu Aug 21, 2008 10:52 am

Re: MsiSetTargetPath does not work

Hi Ionut!

Thanks for giving me your valuable time. I have changed my aip to use "Directory Set with Formatted" on "InstallInitialize" custom action, but , it was of no help.

Actually, i am getting paths of my already installed products then the MSI installed the product on that path, if, there is no product installed, I asked user to specify the path.

So, I used MsiSetProperty(hModule, _T("APPDIR"), _T(strTargetDir.GetBuffer(strTargetDir.GetLength())));
in my customAction.dll which was fired on "Cost Finalize" action. Then I set the APPDIR in "Directory Set with Formatted" on "InstallInitialize".
It gives me following error:
=== Logging stopped: 9/12/2008 11:28:33 ===
MSI (c) (70:4C) [11:28:33:118]: Note: 1: 1708
MSI (c) (70:4C) [11:28:33:118]: Product: X-Analysis -- Installation failed.

I've attached the .log file with this post, plz find the same.

Regards,
Vicky
Attachments
setup1.zip
(29.41 KiB) Downloaded 859 times
vicky
Posts: 66
Joined: Thu Aug 21, 2008 10:52 am

Re: MsiSetTargetPath does not work

Hi Ionut!

Thanks for ur help. The bug reported in my previous post was because of an exception.
Now, everything is going fine, i have called "Directory Set with Formatted" on "InstallInitialize" and set the [APPDIR] on "Cost Finalize".

This was solved my problem, many thanks for support from you guys.

Regards,
Zia

Return to “Common Problems”