Page 1 of 1 1
Topic Options
#211157 - 2016-03-04 05:44 PM get xml version
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
I didn't find a script in the UDF library. So, I started writing one. I'm having a problem with it on Windows 2008 R2 servers. The EnumValue doesn't seem to work even though I can see the value in regedit.

 Code:
Function GetXMLVersion(optional $strComputer)
   DIM $strKey, $intIndex, $intI, $strValName, $arrVer[10]
   If $strComputer = ""
      $strComputer = "."
   EndIf
   ;
   $strKey="\HKEY_CLASSES_ROOT\CLSID\{2933BF90-7B36-11D2-B20E-00C04F983E60}\VersionList"
   $intIndex = 0
   $intI     = 0
   If KeyExist("\\" + $strComputer + $strKey)
      $strValName = EnumValue("\\" + $strComputer + $strKey, $intIndex)
      While Not @ERROR
         If $strValName <> "(Default)"
            ; Want to ignore the Default entry
            $arrVer[$intI] = $strValName
            $intI = $intI + 1
         EndIf
         $intIndex = $intIndex + 1
         $strValName = EnumValue("\\" + $strComputer + $strKey, $intIndex)
      Loop
   EndIf
   ; To mark the end of the array, place a -1 in the next array position.
   $arrVer[$intI] = -1
   $GetXMLVersion = $arrVer
EndFunction

It works fine on 32 bit Windows Server 2003.

Top
#211158 - 2016-03-04 05:54 PM Re: get xml version [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
$ = SetOption(AlternateRegView', 'Off') may be your best friend...

Glenn

PS - the command is from memory - please confirm in the ReadMe or User Guide! \:D
_________________________
Actually I am a Rocket Scientist! \:D

Top
#211160 - 2016-03-04 07:29 PM Re: get xml version [Re: Glenn Barnas]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Hi Glenn,

That was it (WOW64AlternateRegView). Now, that worked when run locally on that server. If I am running from a central server, how do I set that on the 64 bit systems and not on the 32 bit systems? Or, will the 32 bit systems just ignore it? So, having it on always won't hurt?

Regards,

Brad

Top
#211162 - 2016-03-04 09:38 PM Re: get xml version [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Won't affect x86 (since there is no alternate view) or remote queries. \:\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#211166 - 2016-03-05 04:21 PM Re: get xml version [Re: Glenn Barnas]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
here is a complete version of the function with few optimizations and real size for the array.
 Code:
Function GetXMLVersion(optional $strComputer)
  redim $GetXMLVersion[10]
  dim $oldopt, $strKey, $intI

  $strKey="HKEY_CLASSES_ROOT\CLSID\{2933BF90-7B36-11D2-B20E-00C04F983E60}\VersionList"

  If vartype($strComputer) = 0  $strComputer = ""   EndIf
  If $strComputer  $strKey = "\\"+$strComputer+"\"+$strKey   EndIf

  $oldopt = SetOption( "WOW64AlternateRegView", "Off")
  $intI = -1
  If KeyExist( $strKey )
    dim $intIndex, $strValName

    $intIndex = 0
    $strValName = EnumValue( $strKey, $intIndex )
    While Not @ERROR
      If $strValName <> ""
        ; Want to ignore the Default entry
        $intI = $intI + 1
        if $intI > UBound($GetXMLVersion)
          redim preserve $GetXMLVersion[UBound($GetXMLVersion)*2]
        endif
        $GetXMLVersion[$intI] = $strValName
      EndIf
      $intIndex = $intIndex + 1
      $strValName = EnumValue( $strKey, $intIndex)
    Loop
  EndIf
  $oldopt = SetOption( "WOW64AlternateRegView", $oldopt )

  if $intI=-1     exit 1    endif

  redim  preserve $GetXMLVersion[$intI]
  exit 0
EndFunction

;--------------------------------
;  demo
;--------------------------------
$arrVers = GetXMLVersion()
if not @error
  for each $vers in $arrVers
    $vers ?
  next
endif
The main change is that the returned array has no -1 value at the end. you just need to test the macro @error. There is also one optimization for local access (no \\.\) and one optimization on string concatenation (strKey include \\$strcomputer\ when remote access).
_________________________
Christophe

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.052 seconds in which 0.021 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org