cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Awolf401
Level 4

Help with Understanding MsiGetProperty()

Alright, I am completely open to new ideas other then using the function but here is what I am trying to do.

-Take the port number from the user input on my dialog box which is set into property IDDATAPORT (global variable all capitals right?)

-Set the port as open in the firewall. (This part is working flawlessly)

My problem comes trying to use MsiGetProperty. I have used a messagebox to verifiy that even when I set the default value of IDDATAPORT to 25000 it still returns nothing as in blank. So if anybody could tell me what I am doing wrong I would certainly appriciate it. My code is below message boxes just used for debugging:

export prototype configFirewall(HWND);

function configFirewall(hMSI)
string szMsg, svText, formattedText;
string strNetsh;
string strCommandLine, strCommandLine2;
string svValue;
number nvSize, nvType;
number nbSize;

begin
//CtrlGetText("ServerInfo", 27445 ,svText);
MsiGetProperty(ISMSI_HANDLE, "IDDATAPORT", svText, nbSize);
strNetsh = WINSYSDIR^"netsh.exe";
strCommandLine = "firewall add portopening tcp " + svText + " portname enable All";
strCommandLine2= "firewall set opmode enable enable";
MessageBox(strCommandLine, INFORMATION);
LaunchAppAndWait( strNetsh, strCommandLine, LAAW_OPTION_WAIT||LAAW_OPTION_HIDDEN);
LaunchAppAndWait( strNetsh, strCommandLine2, LAAW_OPTION_WAIT||LAAW_OPTION_HIDDEN);
//set registry entry
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
RegDBGetKeyValueEx ("Software\\key name private." , "PortNumber" , nvType , svValue , nvSize );
svValue = svText;
RegDBSetKeyValueEx ("Software\\key name private" , "PortNumber" , REGDB_STRING , svValue , -1 );
end;


Thanks in advance
Labels (1)
0 Kudos
(2) Replies
RobertDickau
Flexera Alumni

A couple of things: before calling MsiGetProperty, you'll want to set the buffer-size argument (nbSize, in your case) to a large enough value to contain the maximum property value.

The first argument to MsiGetProperty probably wants to be the same argument passed to the entry-point function (hMSI, in your case).

That little section would then be:
nbSize = 10; // whatever's right
MsiGetProperty(hMSI, "IDDATAPORT", svText, nbSize);


Having said that, what kind of project is this? If Basic MSI, you might be able to use launch-an-EXE custom actions that use [IDDATAPORT] as an argument, and avoid scripting entirely...
0 Kudos
Awolf401
Level 4

It was my lack of buffersize that did it. Thank you I knew it was something small and stupid I was doing. I definatly appriciate the help.
0 Kudos