Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why can't I get binary data to output?

Status
Not open for further replies.
Feb 11, 2005
153
0
0
US
Okay here is a simple piece of code I am playing around with I am going to tweak it ALOT but the problem I have is I can't get the binary value to output.

Code:
Dim strDate, strTime, OUTPUT_FILE_NAME, strKeyPath1, strKeyPath2
strDate = Replace(Date,"/","-")
strTime = Replace(Time,":","-")
OUTPUT_FILE_NAME = "Checking UID on Active domain machines on "&strDate&" @ "&strTime&".csv"
strComputer = InputBox("1) Ensure Computer is added to the Domain.           2) Powered on.                                                      3) Connected to the network.                                 4) Has no permissions issues.","Enter Computer Name Variable")
IF strComputer = "" THEN
  WScript.Echo "No Computer Name was given or you clicked Cancel"
  WScript.Quit
END IF
Set objFSO = CreateObject("Scripting.FileSystemObject")  
Set objFileOutput = objFSO.CreateTextFile(OUTPUT_FILE_NAME)
  objFileoutput.WriteLine "Device name,LD Common,Intel Common"
const HKLM=&H80000002
Set ObjReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath1 = "SOFTWARE\LANDesk\Common Api"
strKeyPath2 = "SOFTWARE\Intel\LANDesk\Common Api"
ValueName = "UniqueID"
objReg.GetBinaryValue HKLM, strKeyPath1, ValueName, strValue
objReg.GetBinaryValue HKLM, strKeyPath2, ValueName, strValue1
  'WScript.Echo "Value = " & strValue
  'objFileoutput.WriteLine strComputer & ", " & strValue & ", " & strValue1

As you can see these bottom 2 lines are my output attempts I also tried a msg box. I think this has to do with the fact this is a binary string value.

What I want is to do this - search the registry for 2 binary strings and report back the machine name and the 2 binary strings on the same line. The binary strings I would love if they were formatted as you see it when you use regedit but at this point I would be happy to get some kind of output from it.
 
Try this:

Code:
strV1 = objReg.GetBinaryValue HKLM, strKeyPath1, ValueName, strValue
strV2 = objReg.GetBinaryValue HKLM, strKeyPath2, ValueName, strValue1

WScript.Echo "Value = " & strV1  
objFileoutput.WriteLine strComputer & ", " & strV1 & ", " & strV2

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
strValue and strValue1 are out-param. They are _not_ string. They are array of byte. Hence you need to treat array properly and get the result.
 
GetBinaryValue returns the values as an array. You may try using the Join Function to change it into a string.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
WScript.Echo Join(strValue)
WScript.Echo Join(strValue1)

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks guys heres the code I ended up with -

Code:
If objReg.GetBinaryValue( _
    HKLM, strKeyPath1, ValueName, strValue) = 0 Then
      If objReg.GetBinaryValue( _
         HKLM, strKeyPath2, ValueName, strValue1) = 0 Then
     objFileoutput.WriteLine strComputer & ", " & join(strValue) & ", " & join(strValue1) & ",Ensure no other PC on this list has a duplicate number."
         Else
     objFileoutput.WriteLine strComputer & ", " & join(strValue) & ",,Only single UID found LanDesk may not be functional delete UID and reinstall."
      End if
 Else
objFileoutput.WriteLine strComputer & ",,,No UID found please check for LanDesk client"
 End if

While I wrote this to help track down problem Landesk clients maybe someone looking may want to tweak it for their own devices.

Mind me quickly asking why doesn't join make it readable as you would see in the registry. Is it just simply joining the binary numbers and not converting it to hex? If its just doing a join how do I ensure that 2 joined sets of binary don't add up to the same number?

I just want to ensure this number is 100% unique per pc.
 
If you wanted the hex values you could try this:

Code:
objReg.GetBinaryValue HKLM, strKeyPath2, ValueName, strValue1

For i = 0 To UBound(strValue1)
	strOutput = strOutput & Hex(strValue1(i)) & " " 
Next

WScript.Echo strOutput

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top