Well.............. there you have it.
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
:
| Sim wrote:
|
| > The information contained in the registry is in binary, would I have to
| > convert this and enter the correct username?
| Hi
|
| With a VBScript:
|
| '--------------------8<----------------------
| Const HKCU = &H80000001
|
| sComputer = "."
|
| ' Office username to be written to registry
| sUsername = "torgeir"
|
| aUsername = ToByteArray(sUsername)
|
| Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
| & sComputer & "\root\default:StdRegProv")
|
| sKeyPath = "SOFTWARE\MICROSOFT\OFFICE\9.0\COMMON\USERINFO\"
| sValueName = "UserName"
|
| iRC = oReg.SetBinaryValue(HKCU, sKeyPath, sValueName, aUsername)
|
| If iRC <> 0 Then
| 'An error occurred
| WScript.Echo "Error, return code: " & iRC
| WScript.Quit
| End If
|
|
| Function ToByteArray(ByVal sString)
|
| ReDim aBytes(Len(sString) * 2 + 1)
|
| iIndex = -1
| For iPos = 1 To Len(sString)
| iIndex = iIndex + 1
| aBytes(iIndex) = Asc(Mid(sString, iPos, 1))
| ' add a 0 after each letter
| iIndex = iIndex + 1
| aBytes(iIndex) = 0
| Next
|
| ' add two closing 0's
| iIndex = iIndex + 1
| aBytes(iIndex) = 0
| iIndex = iIndex + 1
| aBytes(iIndex) = 0
|
| ToByteArray = aBytes
| End Function
| '--------------------8<----------------------
|
|
| --
| torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
| Administration scripting examples and an ONLINE version of
| the 1328 page Scripting Guide:
|
http://www.microsoft.com/technet/scriptcenter/default.mspx