Run Program As - Environment Variables

Got a problem you cannot solve? Try here.
amolago
Posts: 16
Joined: Wed Oct 29, 2014 9:15 pm

Run Program As - Environment Variables

Postby amolago » Thu Jun 18, 2015 8:18 pm

Hi,

I am using InstallAware 18 (Build 10.23.13) and having the following problem.

I'm trying to add a directory to the PATH environment variable when running a program using "Run Program As". However, on my Windows 7 (64bit) machine I'm testing on, the application never starts. On a Windows XP machine I'm testing on, the application starts, but demonstrates incorrect behavior.

After much testing and trawling through these forums, I've got no closer to an answer, the closest being Run Program As - Environment parameter questions.

I've cut this down to the simplest script that I can (this is the whole script):

Code: Select all

Set Variable LAST_ERROR to
Set Variable CMDRESULT to
Get All Environment Variables into Variable SYSENV
Get Folder Location System->System Directory into WINSYSDIR
Run Program $WINSYSDIR$\CMD.exe /k set (WAIT, get result into variable CMDRESULT)
Call DLL Function kernel32.dll->GetLastError (get result into variable LAST_ERROR)
MessageBox: Finished!, CMDRESULT: $CMDRESULT$$NEWLINE$$NEWLINE$LAST_ERROR: $LAST_ERROR$$NEWLINE$

Code: Select all

~InstallAware Clipboard Data~
~MessageBox~
~{4390FA4C-37B9-44F8-BA78-6B0AE95B735E}~
~Finished!~
~CMDRESULT: $CMDRESULT$$NEWLINE$$NEWLINE$LAST_ERROR: $LAST_ERROR$$NEWLINE$~
~0~
~1~
~~
~Call DLL Function~
~{F49C6CA5-26C1-4D7A-841D-EA2F68C7EFBA}~
~kernel32.dll,GetLastError,"double word",LAST_ERROR,$~
~mIDEFunc.dll\mEXEFunc.dll~
~Run Program As~
~{B3384F1D-3869-46F9-B151-279C268ED5A6}~
~$WINSYSDIR$\CMD.exe~
~~
~/k set~
~0~
~~
~~
~~
~CMDRESULT~
~TRUE~
~$SYSENV$~
~Get Folder Location~
~{5C7ACF51-14A4-40D4-8CFD-C5FE5E91C795}~
~WINSYSDIR~
~23~
~FALSE~
~Get Environment~
~{0831297B-9D81-4EF4-B8EC-F726F17ADA44}~
~~
~SYSENV~
~Set Variable~
~{18962834-63D7-4021-9177-E5D76FC5C091}~
~CMDRESULT$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{CD6A70E6-1F98-49C2-AFA2-5F5F1EB3008C}~
~LAST_ERROR$MYAH$MYAH$FALSE~
~~

When run on Windows XP, the CMD window displayed shows:

Code: Select all

A
L
L
U
S
E
R
S
P
R
O
F
I
L
E
C
:
D
o
c
u
m
e
n
t
s

a
n
d

S
e
t
t
i
n
g
s
A
l
l

U
s
e
r
s
COMSPEC=C:\WINDOWS\system32\CMD.exe
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS
PROMPT=$P$G

And the Message Box shows:
CMDRESULT: -1073741510
LAST_ERROR: 0

On Windows 7, there is no CMD window, and the Message Box shows:
CMDRESULT: -11
LAST_ERROR: 0

If i cut the Environment variable right back to a single value:

Code: Select all

~InstallAware Clipboard Data~
~Run Program As~
~{B3384F1D-3869-46F9-B151-279C268ED5A6}~
~$WINSYSDIR$\CMD.exe~
~~
~/k set~
~0~
~~
~~
~~
~CMDRESULT~
~TRUE~
~ENV=VALUE~

Still nothing on Windows 7, while Windows XP shows:

Code: Select all

E
N
V
V
A
L
U
E
COMSPEC=C:\WINDOWS\system32\CMD.exe
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS
PROMPT=$P$G


Do you have any idea why the application won't run on Windows 7? Is it something to do with the Unicode values IA is using to set the Environment Variables?

Chris

EDIT: When using a blank value for "Environtment", the CMD window on both Windows 7 and XP appears correctly and show the same values in the Message box:
CMDRESULT: -1073741510
LAST_ERROR: 0

amolago
Posts: 16
Joined: Wed Oct 29, 2014 9:15 pm

Re: Run Program As - Environment Variables

Postby amolago » Thu Jun 18, 2015 9:11 pm

Just another note:

I've also tried adding CODEPAGE=1252 and LOCMODE=VARSONLY, to the compiler variables, and also tried adding "Set Variable CHARSET_OVERRIDE to ANSI_CHARSET"

Code: Select all

~InstallAware Clipboard Data~
~Set Variable~
~{9F75AA06-352D-4602-AE9A-CB3F50A1AE64}~
~CHARSET_OVERRIDE$MYAH$MYAH$FALSE~
~ANSI_CHARSET~


All to no avail.

Chris

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Run Program As - Environment Variables

Postby FrancescoT » Fri Jun 19, 2015 12:58 pm

Dear Chris,

please excuse me, but it's not really clear to me what are you trying to achieve.

if you need to set an environment variable at setup Runtime, why do you not use the "Set Environment Variable" command?

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

amolago
Posts: 16
Joined: Wed Oct 29, 2014 9:15 pm

Re: Run Program As - Environment Variables

Postby amolago » Fri Jun 19, 2015 7:45 pm

Hi Francesco,

I did think of that, but I don't need/want to set the PATH variable permanently.

The application I'm attempting to run is "c:\windows\system32\regsvr32.exe", after "Apply Install" has been executed, against the sole DLL we install. The setup is installing this DLL into a directory of the main application which has already been installed separately, this is an add-on if you will.

It fails because two other DLLs required by our add-on are not on the system search path, they're already installed in the main application directory. My idea was that I could use "Run Program As", adding the application directory to the PATH environment variable, to execute regsvr32.exe on the DLL. Tests outside of IA (i.e. within a CMD window on the test machine), showed this idea to be successful, and when I found "Run Program As", I thought that it would suit me needs.

However, as stated, the "regsvr32.exe" never executes on Windows 7, and returns a value of -11 to the specified return variable.

So I was wondering if this is a bug, or maybe I'm trying to do something incorrectly or achieve something IA isn't able to do.

Chris

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Run Program As - Environment Variables

Postby FrancescoT » Mon Jun 22, 2015 1:01 pm

Dear Chris,

first of all, if the setup process that should execute regsvr32.exe already runs in elevated mode, there is no need to explicitly use "Run Program As" and it's enough to call the standard "Run Program" command. The effects in this case are identical.

For what concerns your dlls path and if I have not missed anything, the dll that has to be registered and the other two DLLs required to successfully register it, are all stored within the same target folder. If this is true it's not necessary to specify any path with the system, because the default DLL search order tries as first, to use the directory specified with the "<full path of the DLL to register>" passed to regsvr32.exe.

That said and if you are experiencing this issue on a x64 target OS, are you calling the correct "regsvr32.exe" version?

On a 64-bit version of Windows operating system, there are two versions of the Regsv32.exe file:
•The 64-bit version is %systemroot%\System32\regsvr32.exe.
•The 32-bit version is %systemroot%\SysWoW64\regsvr32.exe.
https://support.microsoft.com/en-us/kb/249873

If you need to register a native x86 dll on a 64-bit version OS, you need to call the "Regsv32.exe" tool under "SysWoW64".

Finally, could you please describe a little bit more the steps you used to manually register the Dll along with the command line issued?

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 90 guests