cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
brisnick
Level 3

Replace Hardcoded Computer Name (Fully Qualified)

Hi, I have an MSI that I want to change a hardcoded computername in three registry keys.

The MSI was created with AdminStudio (9.5)

The three keys are formatted such as:

computername.domain.com
computername
\\computername.domain.com\folder

I believe I should be able to change the actual hardcoded name with [ComputerName] to give the short name, but how do I capture the fully-qualified computer name during install??

Regards,
Nick
Labels (1)
0 Kudos
(4) Replies
smithapal
Level 2

Hi Nick,

I have the same issue as yours. Just wondering If you have found any solution to this.

I tried to change keys as
%COMPUTERNAME%.%USERDNSDOMAIN%
%COMPUTERNAME%
\\%COMPUTERNAME%.%USERDNSDOMAIN%\folder

Even tried square brackets instead of '%' like [COMPUTERNAME], but not successful. It just gives the same value instead of pulling the current computer name.

If you have find the solution for this issue Please reply me.

Thanks and Regards,
Smitha
0 Kudos
RobertDickau
Flexera Alumni

In Windows Installer, you can use [%VARNAME] to expand the value of an environment variable at run time.
0 Kudos
smithapal
Level 2

Thank you Robert
0 Kudos
jchaffier
Level 2

If this helps anyone, because I was in the same boat looking for computer name, here are the prototypes and the function I created to do this. I call this custom action before the PatchWelcome call in the UI path.

export prototype SetComputerName(HWND);
prototype BOOL KERNEL32.GetComputerName(BYREF STRING, BYREF NUMBER);
prototype BOOL KERNEL32.GetComputerNameEx(NUMBER, BYREF STRING, BYREF NUMBER);

//Function Definitions
//---------------------------------------------------------------------------------------//

function SetComputerName(hWND)
//Desclare local variable
NUMBER result, computerNameFormat, size;
STRING computerName;

//CODE NOTE:
//The difference between the two calls is that the GetComputerName function doesnt include
//the domain portion of the NetBIOS name of the machine running the installation.

begin
//Set the fully qualified computer name for the Web Host Name
size = 255;
computerNameFormat = 3; //Enumeration value to determine which name to return. See COMPUTER_NAME_FORMAT in the MSDN
result = GetComputerNameEx(computerNameFormat, computerName, size);
result = MsiSetProperty(hWND, "FULL_COMPUTER_NAME", computerName);

//Set the comuter name to represent the SQL Server instance name
result = GetComputerName(computerName, size);
result = MsiSetProperty(hWND, "SHORT_COMPUTER_NAME", computerName);

end;
0 Kudos