This is something that I have to once and will never have to do it again. I want to create REG_BINARY from a string. There's a program that encodes the password and stores it in the registry as REG_BINARY. I have copied the REG_BINARY and stored it in my database as varchar (i.e. string). So, whenever user logs in to any computer in the network, this REG_BINARY needs to be applied to the Registry value.
Here's what I tried.
Set oShell = CreateObject("WScript.Shell")
Set oFso = CreateObject("Scripting.FileSystemObject")
'Create the ADsystem Information Object
Set objADSystemInfo = CreateObject("ADSystemInfo")
'Get the current information into a new object
Set objUser = GetObject("LDAP://" & objADSystemInfo.UserName)
'Office Details
oShell.RegWrite "HKCU\Software\Microsoft\Office\Common\UserInfo\UserInitials", objUser.sAMAccountName, "REG_SZ"
oShell.RegWrite "HKCU\Software\Microsoft\Office\Common\UserInfo\UserName", objUser.givenName & " " & objUser.sn, "REG_SZ"
On Error Resume Next
'Connect to MySQL Database
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=members;"
objRecordset.CursorLocation = adUseClient
objRecordset.ActiveConnection = objConnection
objRecordset.Open "SELECT * FROM members WHERE USER_ID = '" & objUser.sAMAccountName & "'"
aRegPath = "HKCU\Software\KONICA MINOLTA\KONICA MINOLTA 350/250/200 VXL\AccountTrack\"
oShell.RegWrite aRegPath & "DepartmentName", objRecordset("USER_ID"), "REG_SZ"
oShell.RegWrite aRegPath & "DepartmentPass", objRecordset("DEPARTMENT_PASS"), "REG_BINARY"
The USER_ID shows up in the registry, but not the DEPARTMENT_PASS. I think it's cause the department_pass is stored as string. The value of the department_pass from the database is:
be 2e 31 df ff 53 ca 35 f8 32 90 22 fc 44 4b 66 f8 32 90 22 fc 44 4b 66 f8 32 90 22 fc 44 4b 66 f8 32 90 22 fc 44 4b 66 f8 32 90 22 fc 44 4b 66 f8 32 90 22 fc 44 4b 66 f8 32 90 22 fc 44 4b 66 32 88 64 99 7b ab 8d 3c
The registry needs to show this value exactly the way it is. How can I do this?