Comments (1)

  1. Chris Allanson says:

    Hi, Nice article, the following does a very similar thing too thought I'd share it.

    const HKEY_CURRENT_USER = &H80000001

    strComputer = "."

    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_

    strComputer & "rootdefault:StdRegProv")

    Set objNetwork = WScript.CreateObject("WScript.Network")

    strUserName = objNetwork.UserName

    'connect to AD for info

    Dim objADSysInfo : Set objADSysInfo = CreateObject("ADSystemInfo")

    Dim objUser : Set objUser = GetObject("LDAP://" & objADSysInfo.UserName)

    strFNLN = objUser.FirstName & " "& objUser.LastName

    strInitials = Left(objUser.FirstName,1) & Left(objUser.LastName,1)

    'wscript.echo strInitials

    strKeyPath = "SoftwareMicrosoftOfficeCommonUserInfo"

    strValueName = "UserName"

    'oReg.GetExpandedStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

    oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strFNLN

    'oReg.GetExpandedStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

    strValueName = "UserInitials"

    oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strInitials

    strValueName = "Company"

    oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,"Leeds City College"

    strKeyPath = "SoftwareMicrosoftOfficeCommon"

    strValueName = "Username"

    oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strUserName

    'WScript.Echo objUser.Mail & objUser.LastName & objUser.FirstName

    WScript.quit

Skip to main content