Hi everyone,
I'm a bit of a newbie when it comes to scripting, but I'm learning at a reasonable pace. I'm attempting to write a script that will set the Office XP username and user initials in the windows registry through Active Directory automatically when the user logs into the domain. I'm doing this using VBScript. Unfortunately I have found no easy way to convert to hexadecimal in order to put the registry key in the registry. Too bad Microsoft couldn't just put the values in the registry as string to be easier to manage.
Anyway, I start off by getting the username from login using the WScript.Network Username method - no problem. I then create the object for WScript.Shell for registry access. The problem I'm having is this: I convert the username from string to ascii code using this code...
' Create WSH objects
Set nw = CreateObject("WScript.Network"
Set WshShell = CreateObject("WScript.Shell"
'Get username
strUserName = nw.username
'Get length of username
max = len(strUserName)
'Start Processing username (Have to do it backwards because that's how it needs to go into the reg)
For intLoop = max to 1 step -1
'convert to ascii
asciiName = asc(mid(strUserName, intLoop, 1))
'convert to hex
hexName = hex(asciiName)
'concatenate hex string
newUserName = newUserName & hexName
Next
msgbox newUserName
What I do after this - I have no clue. How do I get the newUserName variable back as an integer? The registry writes I have no problem with - it's just the conversion back to integer that has me stuck.
I know in VB the function Val() will convert a string to numbers - barring any non-numerical characters other than &H or &O signifying Hexadecimal and Octal numbering systems, but I guess val() doesn't work with VBScript. Is this due to a limitation in VBScript or is this an oversight on my part? Any suggestions on how I could make this happen would be greatly appreciated.
Regards,
James Rogers
Systems Engineer
University of Notre Dame
MCSE MCSA MCDBA
I'm a bit of a newbie when it comes to scripting, but I'm learning at a reasonable pace. I'm attempting to write a script that will set the Office XP username and user initials in the windows registry through Active Directory automatically when the user logs into the domain. I'm doing this using VBScript. Unfortunately I have found no easy way to convert to hexadecimal in order to put the registry key in the registry. Too bad Microsoft couldn't just put the values in the registry as string to be easier to manage.
Anyway, I start off by getting the username from login using the WScript.Network Username method - no problem. I then create the object for WScript.Shell for registry access. The problem I'm having is this: I convert the username from string to ascii code using this code...
' Create WSH objects
Set nw = CreateObject("WScript.Network"
Set WshShell = CreateObject("WScript.Shell"
'Get username
strUserName = nw.username
'Get length of username
max = len(strUserName)
'Start Processing username (Have to do it backwards because that's how it needs to go into the reg)
For intLoop = max to 1 step -1
'convert to ascii
asciiName = asc(mid(strUserName, intLoop, 1))
'convert to hex
hexName = hex(asciiName)
'concatenate hex string
newUserName = newUserName & hexName
Next
msgbox newUserName
What I do after this - I have no clue. How do I get the newUserName variable back as an integer? The registry writes I have no problem with - it's just the conversion back to integer that has me stuck.
I know in VB the function Val() will convert a string to numbers - barring any non-numerical characters other than &H or &O signifying Hexadecimal and Octal numbering systems, but I guess val() doesn't work with VBScript. Is this due to a limitation in VBScript or is this an oversight on my part? Any suggestions on how I could make this happen would be greatly appreciated.
Regards,
James Rogers
Systems Engineer
University of Notre Dame
MCSE MCSA MCDBA