Archive: Retrieving Primary Domain from Multiple domain computer


Retrieving Primary Domain from Multiple domain computer
Hope someone can help with this one.

I have a program for a multiple domain company, IE; ABC, 123, USA domains.

The program will be used in all domains, but since we have a problem with Cross domain membership, we have a service account setup for each domain. Domain ABC, Domain 123, and Domain USA.

I have the ServiceLib plugin and I am able to successfully install the program (and service) in windows but ONLY when I manually place the DOMAIN name into the user field, IE ABC\administrator.

What I would like to do, is pull the primary domain (or rather the domain that the PC is a member of) and insert into the script so that they ONE script can be used for mulitple domains.

Might sound easy, I haven't found anything on google or in the forums yet. I know that I might pull this variable from the registry (which Im trying to stay away from) or could I use a WMI/API call to get the primary Domain?

Any help will be appreciated. Thanks!


Don't know if this will help, but could you read the Environmental Variable "USERDOMAIN"?

Like this:


ReadEnvStr $1 "USERDOMAIN"

Sorry if I'm way off, just thought I would throw that out there. Good luck.

Yes, but I think the problem with reading the environment variable is that it returns the user's domain... so, if I am logged on as a local adminstrator, it will return the PCs name. Or.. If I am logged on to another domain, it doesnt pull the primary domain of the PC.

I can try this.

How do I read the variable and then use later in the script? Just reference $1?

Thanks--


Originally posted by Kappaphi189
How do I read the variable and then use later in the script? Just reference $1?
Yup:
ReadEnvStr $1 "USERDOMAIN"
MessageBox MB_OK "The domain is '$1'."

This displays a message box with the message: The domain is 'MYDOMAIN'.

Thanks.

I'll try that out and see what I can develop.

Whats the code for reading from the Registry? READRgstr?


Per the User Manual:

4.9.2.11 ReadRegDWORD
user_var(output) root_key sub_key name
Reads a 32 bit DWORD from the registry into the user variable $x. Valid values for root_key are listed under WriteRegStr. The error flag will be set and $x will be set to an empty string ("" which is 0) if the DWORD is not present. If the value is present, but is not a DWORD, it will be read as a string and the error flag will be set.

ReadRegDWORD $0 HKLM Software\NSIS VersionBuild
4.9.2.12 ReadRegStr
user_var(output) root_key sub_key name
Reads from the registry into the user variable $x. Valid values for root_key are listed under WriteRegStr. The error flag will be set and $x will be set to an empty string ("") if the string is not present. If the value is present, but is of type REG_DWORD, it will be read and converted to a string and the error flag will be set.

ReadRegStr $0 HKLM Software\NSIS ""
DetailPrint "NSIS is installed at: $0"