Jump to content

Office 2003 User Information


jfmartel

Recommended Posts

You know when you are launching for the first time any Office apps (Word, Excel, etc) from a newly created user profile, the installer start and then ask for a Username and Initials

I found where this information is located....the problem is that the information stored about the user (name and initials) is stored in HEX !!!!!

Key located in:

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]

I know this could be very easy to just enter anything there and then copy the whole key and load it in the .reg file that loads from the cmdline.txt.

But, in my corporate environment, these key are very used for our template file.

Thank you!

Link to comment
Share on other sites


I think its possible to change it at will.

You just need to do it through REG.EXE instead of regedit imports.

That way,  you can specify the userinfo in your batch-file and it gets imported.

I'm not sure of what u mean by this

What is REG.EXE and how i use it, and when i use it?

Thank you!

Link to comment
Share on other sites

I'd like to have more information how to do that

Tried

REG ADD HKCU\Software\Microsoft\Office\11.0\Common\UserInfo /v UserInfo /t REG_BINARY /d %%UserName%%

Says "Too many command-lines in parameters"

Tried with BINARY data such as 00010101 and it works..... so it really needs a BINARY data.... how do I convert STRING TO BINARY?

Thank you!

Link to comment
Share on other sites

you need to do it with vsb script

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")

' get UserName
strUsername = oShell.ExpandEnvironmentStrings("%USERNAME%")

' Convert UserName to hex
For i = 1 to Len(strUsername)
  strUsernameHex = strUsernameHex & "," & Hex(Asc(Mid(strUsername, i, 1))) & ",00"
Next
strUsernameHex = Right(strUsernameHex, Len(strUsernameHex) -1)
strUsernameHex = strUsernameHex & ",00,00"

' Create temporary registry file
Const OverwriteIfExist = -1
Const FailIfExist      = 0
Const OpenAsASCII   =  0
Const OpenAsUnicode = -1
Const OpenAsDefault    = -2
sTmpFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UserInfo.reg"
Set fFile = oFSO.CreateTextFile(sTmpFile, OverwriteIfExist, OpenAsASCII)

' Write to the temporary registry file
fFile.WriteLine "REGEDIT4"
fFile.WriteLine
fFile.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]"
fFile.WriteLine """UserName""=hex:" & strUsernameHex
fFile.Close

' Import the registry file
oShell.Run "regedit /s " & sTmpFile, 0, True

' Delete the temporary registry file
oFSO.DeleteFile sTmpFile

Link to comment
Share on other sites

Thank you. That was a good help

I've finally managed to get my full answer....

In our business... the username will be use as Initials for Office.

What this code do is search the Active Directory for the current username. Then get the Full name (Will be use as Full name within Office) then convert the string to HEX.

So here the code, executed at the logon

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")

' get UserName
strName = oShell.ExpandEnvironmentStrings("%USERNAME%")

strContainer = "ou=MyOUInAD"

On Error Resume Next

' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_DOMAIN = 1
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1179 = 1

Set objNetwork = CreateObject("Wscript.Network")

' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

' Use the NameTranslate object to find the NetBIOS domain name from the
' DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_TYPE_NT4, strDNSDomain
objTrans.Set ADS_NAME_TYPE_1179, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)

' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
objTrans.Init ADS_NAME_INITTYPE_DOMAIN, strNetBIOSDomain
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strName
strUserDN = objTrans.Get(ADS_NAME_TYPE_1179)

' Bind to the user object in Active Directory with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)

'Get Common name
strUsername= objUser.cn

'Convert Initials to HEX
For i = 1 to Len(strName)
 strInitialsHex = strInitialsHex & "," & Hex(Asc(Mid(strName, i, 1))) & ",00"
Next
strInitialsHex = Right(strInitialsHex , Len(strInitialsHex ) -1)
strInitialsHex = strInitialsHex & ",00,00"

'Convert Username to HEX
For i = 1 to Len(strUsername)
 strUsernameHex = strUsernameHex & "," & Hex(Asc(Mid(strUsername, i, 1))) & ",00"
Next
strUsernameHex = Right(strUsernameHex, Len(strUsernameHex) -1)
strUsernameHex = strUsernameHex & ",00,00"

' Create temporary registry file
Const OverwriteIfExist = -1
Const FailIfExist      = 0
Const OpenAsASCII   =  0
Const OpenAsUnicode = -1
Const OpenAsDefault    = -2
sTmpFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UserInfo.reg"
Set fFile = oFSO.CreateTextFile(sTmpFile, OverwriteIfExist, OpenAsASCII)


' Write to the temporary registry file
fFile.WriteLine "Windows Registry Editor Version 5.00"
fFile.WriteLine
fFile.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]"
fFile.WriteLine """UserName""=hex:" & strUsernameHex
fFile.WriteLine """UserInitials""=hex:" & strInitialsHex
fFile.Close

' Import the registry file
oShell.Run "regedit /s " & sTmpFile, 0, True

' Delete the temporary registry file
oFSO.DeleteFile sTmpFile

'Connect to network drive
Set oNetwork = WScript.CreateObject("WScript.Network")
oNetwork.MapNetworkDrive "z:", "%logonserver%\%username%\home"

Hope this help for someone else too

Thank you all for helping me out on this one

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...