Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to pass environment block to LaunchAppandWait


4 replies to this topic

vishnub

vishnub
  • Full Members
  • 63 posts

Posted 17 November 2004 - 16:12

Hi All,

I am using InstallScriptMsi project, in which i am using LaunchAppandWait to launch an application. In turn that application needs a dll to initiate. I am setting the dll's path in the Path(environment variable) after copying the file, which is followed by launching the application. But the value which i set to the environment variable is not reflected to the application. So the application failed to execute.

For that i pass the environment block to the LaunchAppandWait, as follows

szEnvPath = INSTALLDIR ^ "sample.dll";

LAAW_PARAMETERS.lpEnvironment = &szEnvPath;

Still the application can't able to get the path, what i did is correct, or any other solution to solve this problem.


Thanking you in Advance,

Gratefully,
Vishnu smile.gif


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 18 November 2004 - 08:59

Shouldn't you prepend the path with "PATH=" ?

vishnub

vishnub
  • Full Members
  • 63 posts

Posted 18 November 2004 - 09:57

This is the part of the script which i have used to laucnch the application. Here i got the existing value of the path and appended it with the szEnvPath also.

ENV_TEMP ="Path";

if (GetEnvVar (ENV_TEMP, svEnvVar) < 0) then
MessageBox ("Environment variable " + ENV_TEMP + " not found.", SEVERE);
endif;

svShared = INSTALLDIR ^ "sample.dll";

szEnvPath = "Path=" + svEnvVar + svShared + "\\0";

LAAW_PARAMETERS.lpEnvironment = &szEnvPath;

if(LaunchAppAndWait(szProgram,szCmdLine,LAAW_OPTION_NO_CHANGEDIRECTORY|LAAW_OPTION_WAIT )<0)then
MessageBox("Can't able to launch",0);
else
nResult = LAAW_PARAMETERS.nLaunchResult;
svError=FormatMessage(nResult);
if(nResult != 0)then
SprintfBox(INFORMATION,"Application Failed","%s",svError);
endif;
endif;


One more approach what i tried is, i set the PATH environment variable after copying files and broadcasted as follows

#define WM_WININICHANGE 0x001A
#define HWND_BROADCAST 0xffff

szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );

Even now the paths are not available at the time of launching the application. But after the installation, i can able to do it manually.

Let me know, if there is any mistake or give me an solution to solve this problem.


Gratefully,
Vishnu smile.gif

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 18 November 2004 - 15:32

Try this:
szEnvPath = "PATH=" + svEnvVar + ";" svShared + "\\0";
// (not sure if case of PATH matters, but I think you need the semicolon)

Also you could try to converrt svShared to short path (~ form).

Can you call a simple test.exe that displays the value of PATH in a message box?

vishnub

vishnub
  • Full Members
  • 63 posts

Posted 22 November 2004 - 11:50

I tried like the following,

szEnvPath = "PATH=" + svEnvVar + ";" + svShared + "\\0\\0\\0\\0";

According to this link,
http://msdn.microsof...eateprocess.asp

"A Unicode environment block is terminated by four zero bytes: two for the last string, two more to terminate the block."


I added the following codes also, for the dwCreationFalgs parameter, i included CREATE_UNICODE_ENVIRONMENT and CREATE_NEW_CONSOLE flags also. I trying to launch an jar file, so i hope if i create new console it will reflect the changes in the PATH variable.

LAAW_PARAMETERS.lpEnvironment = &svEnvPath;
LAAW_PARAMETERS.dwCreationFlags = LAAW_PARAMETERS.dwCreationFlags | 0x00000400 | 0x00000010;

Still the problem is not solved.
Please, Check what i did is correct ?

Thanks,
Vishnu