Check for Username=Computername

Got a problem you cannot solve? Try here.
Post Reply
Balanced-Plus
Posts: 31
Joined: Sat Aug 28, 2010 9:06 pm
Contact:

Check for Username=Computername

Post by Balanced-Plus »

Hi,

How can I check if the Windows Username is the same as the Computername?

I need to know this because SQL Server won't install if this is the case.
see: http://dotnetfish.blogspot.com/2009/02/ ... o-not.html

Thanks,
Stef
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Check for Username=Computername

Post by giaviv »

Dear Stef,

In the MSIcode tab, you will find a "Get System Settings" command (under "System Information"). You will then select the "Logged on User Name" capability and insert the result into variable X. Do the same for capability "Logged on Computer Name" and put it in variable Y. All you need to do now is check if X equals Y.

Good luck!
Aviv Giladi
InstallAware Support
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Balanced-Plus
Posts: 31
Joined: Sat Aug 28, 2010 9:06 pm
Contact:

Re: Check for Username=Computername

Post by Balanced-Plus »

Thank you. It works perfectly.

Code: Select all

Set Variable MY_USERNAME to UNKNOWN
Set Variable MY_COMPUTERNAME to UNKNOWN
Get System Setting Logged on User Name into MY_USERNAME
Get System Setting Logged on Computer Name into MY_COMPUTERNAME

if Variable MY_USERNAME Equals MY_COMPUTERNAME
  MessageBox: $TITLE$ Setup Error, Username and Computername are equal.$NEWLINE$Please change Computername to install SQL Server.$NEWLINE$$NEWLINE$Setup cannot continue.
  Terminate Installation
end
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Check for Username=Computername

Post by giaviv »

Dear Stef,

I'm happy that it worked out!
A small note though - you don't need the "Set Variable MY_USERNAME to UNKNOWN":
Variables must be explicitly declared before they can be used in If commands, dialog boxes, or plug-in actions. Commands that write to variables automatically declare them, as long as the command is not dependent on the input value of the variable.
Thank you for your interest in InstallAware,
Aviv Giladi
InstallAware Support
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Balanced-Plus
Posts: 31
Joined: Sat Aug 28, 2010 9:06 pm
Contact:

Re: Check for Username=Computername

Post by Balanced-Plus »

So probably I won't need this line either.
Set Variable MY_COMPUTERNAME to UNKNOWN

One reason I declared them, is that you can select the variable from a list. Otherwise you have to enter them manually (could easy result in typos).
Post Reply