jfmartel Posted January 26, 2005 Share Posted January 26, 2005 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 InitialsI 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 More sharing options...
prathapml Posted January 26, 2005 Share Posted January 26, 2005 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. Link to comment Share on other sites More sharing options...
jfmartel Posted January 27, 2005 Author Share Posted January 27, 2005 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 thisWhat is REG.EXE and how i use it, and when i use it?Thank you! Link to comment Share on other sites More sharing options...
jfmartel Posted February 1, 2005 Author Share Posted February 1, 2005 I'd like to have more information how to do thatTried 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 More sharing options...
asbsamsf Posted February 2, 2005 Share Posted February 2, 2005 you need to do it with vsb scriptSet oFSO = CreateObject("Scripting.FileSystemObject")Set oShell = CreateObject("Wscript.Shell")' get UserNamestrUsername = oShell.ExpandEnvironmentStrings("%USERNAME%")' Convert UserName to hexFor i = 1 to Len(strUsername) strUsernameHex = strUsernameHex & "," & Hex(Asc(Mid(strUsername, i, 1))) & ",00"NextstrUsernameHex = Right(strUsernameHex, Len(strUsernameHex) -1)strUsernameHex = strUsernameHex & ",00,00"' Create temporary registry fileConst OverwriteIfExist = -1Const FailIfExist = 0Const OpenAsASCII = 0Const OpenAsUnicode = -1Const OpenAsDefault = -2sTmpFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UserInfo.reg"Set fFile = oFSO.CreateTextFile(sTmpFile, OverwriteIfExist, OpenAsASCII)' Write to the temporary registry filefFile.WriteLine "REGEDIT4"fFile.WriteLinefFile.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]"fFile.WriteLine """UserName""=hex:" & strUsernameHexfFile.Close' Import the registry fileoShell.Run "regedit /s " & sTmpFile, 0, True' Delete the temporary registry fileoFSO.DeleteFile sTmpFile Link to comment Share on other sites More sharing options...
jfmartel Posted February 4, 2005 Author Share Posted February 4, 2005 Thank you. That was a good helpI'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 logonSet oFSO = CreateObject("Scripting.FileSystemObject")Set oShell = CreateObject("Wscript.Shell")' get UserNamestrName = oShell.ExpandEnvironmentStrings("%USERNAME%")strContainer = "ou=MyOUInAD"On Error Resume Next' Constants for the NameTranslate object.Const ADS_NAME_INITTYPE_DOMAIN = 1Const ADS_NAME_TYPE_NT4 = 3Const ADS_NAME_TYPE_1179 = 1Set 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, strDNSDomainobjTrans.Set ADS_NAME_TYPE_1179, strDNSDomainstrNetBIOSDomain = 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, strNetBIOSDomainobjTrans.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 namestrUsername= objUser.cn'Convert Initials to HEXFor i = 1 to Len(strName) strInitialsHex = strInitialsHex & "," & Hex(Asc(Mid(strName, i, 1))) & ",00"NextstrInitialsHex = Right(strInitialsHex , Len(strInitialsHex ) -1)strInitialsHex = strInitialsHex & ",00,00"'Convert Username to HEXFor i = 1 to Len(strUsername) strUsernameHex = strUsernameHex & "," & Hex(Asc(Mid(strUsername, i, 1))) & ",00"NextstrUsernameHex = Right(strUsernameHex, Len(strUsernameHex) -1)strUsernameHex = strUsernameHex & ",00,00"' Create temporary registry fileConst OverwriteIfExist = -1Const FailIfExist = 0Const OpenAsASCII = 0Const OpenAsUnicode = -1Const OpenAsDefault = -2sTmpFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UserInfo.reg"Set fFile = oFSO.CreateTextFile(sTmpFile, OverwriteIfExist, OpenAsASCII)' Write to the temporary registry filefFile.WriteLine "Windows Registry Editor Version 5.00"fFile.WriteLinefFile.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]"fFile.WriteLine """UserName""=hex:" & strUsernameHexfFile.WriteLine """UserInitials""=hex:" & strInitialsHex fFile.Close' Import the registry fileoShell.Run "regedit /s " & sTmpFile, 0, True' Delete the temporary registry fileoFSO.DeleteFile sTmpFile'Connect to network driveSet oNetwork = WScript.CreateObject("WScript.Network")oNetwork.MapNetworkDrive "z:", "%logonserver%\%username%\home"Hope this help for someone else tooThank you all for helping me out on this one Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now