How combine Logon Server and Logon Domain into same field on BGInfo

33 views Asked by At

I am trying to combine the Logon Server and Logon Domain fields on BGInfo so they are on the same line and have a dote to separate them, so Logon Server.Logon Domain. The script I have retrieves the Logon Domain and combines the computer name but I can't find anything to retrieve the Logon Server.

 Set objNetwork = CreateObject("WScript.Network")
 strLogonServer = objNetwork.UserDomain
 strLogonDomain = objNetwork.ComputerName

 Set objShell = CreateObject("WScript.Shell")
 objShell.Popup strLogonServer & "." & strLogonDomain

Ive tried changing the Logon Domain string to obj.network.UserServer but that doesn't change it.

I also know that CMD produces the logon server via Echo %logonserver% but not sure how to implement that into the string

EDIT:

Created a solution,

Function ReadFromRegistry(strRegistryKey, strDefault) Dim WSHShell, value

On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
value = WSHShell.RegRead( strRegistryKey )

If err.number <> 0 Then
    readFromRegistry = strDefault
Else
    readFromRegistry = value
End If

Set WSHShell = Nothing

End Function

dim objShell dim strLoginServer dim strLoginUser

Set objShell = CreateObject("WScript.Shell")

strLogonServer = ReadFromRegistry("HKEY_CURRENT_USER\Volatile Environment\LOGONSERVER", "error") strLoginUser = ReadFromRegistry("HKEY_CURRENT_USER\Volatile Environment\USERDOMAIN", "error")

strLogonServer = replace(strLogonServer, "", "")

Echo strLogonServer & "." & strLoginUser

Outputs the LogonServer and LogonDomain from registry as an echo with a dot in the middle.

0

There are 0 answers