Hi Jim!
Can WHS be used with the computer?
If so, please try this.
Sub test()
MsgBox "ComputerName " & ComputerName & ":" & _
"UserName" & ":" & UserName
End Sub
Function UserName() As String
Dim objWSH As Object
Set objWSH = CreateObject("WScript.Network")
UserName = objWSH.UserName
Set objWSH = Nothing
End Function
Function ComputerName() As String
Dim objWSH As Object
Set objWSH = CreateObject("WScript.Network")
ComputerName = objWSH.ComputerName
Set objWSH = Nothing
End Function
Not sure about WHS but I did get what I wanted with the following code:
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" ( _
ByVal lpBuffer As String, nSize As Long) As Long
Function UserLoggedIn() As String
Dim MyString As String
Dim StringLen As Long
MyString = String(255, Chr(0))
StringLen = Len(MyString) - 1
GetUserName MyString, StringLen
UserLoggedIn = Trim(MyString)
End Function