Skip to content

Commit

Permalink
Merge pull request #13 from Djily90/fix_empty_xml
Browse files Browse the repository at this point in the history
Fix empty xml
  • Loading branch information
Lea9250 authored Oct 5, 2023
2 parents 72e7b06 + 3f511a1 commit 0c3f1ec
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 46 deletions.
5 changes: 5 additions & 0 deletions agent/Unix/teamviewer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ sub teamviewer_inventory_handler {
# Suppress unused spaces
$team_id =~ s/\s+//g;
$team_version =~ s/\s+//g;


if($team_id == "" || $team_id == $null){
$team_id = "No data available in table"
}

push @{$common->{xmltags}->{TEAMVIEWER}},
{
Expand Down
45 changes: 45 additions & 0 deletions agent/Windows/teamviewer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<#
.SYNOPSIS
This script retrieves TeamViewer's ClientID and Version from the registry
and outputs the result in an XML format.
.DESCRIPTION
It considers both 32-bit and 64-bit OS architectures.
#>

$xml = $null

# Declare the registry path
$regPath = ""

# Initialize the registry path based on the architecture
if(Test-Path "HKLM:\SOFTWARE\WOW6432Node\TeamViewer")
{
$regPath = "HKLM:\SOFTWARE\WOW6432Node\TeamViewer"
}
if(Test-Path "HKLM:\SOFTWARE\TeamViewer")
{
$regPath = "HKLM:\SOFTWARE\TeamViewer"
}

if (Test-Path $regPath)
{
# Try to get TeamViewer ClientID from the registry
$teamViewer = (Get-ItemProperty -Path $regPath) | ForEach-Object {
$xml += "<TEAMVIEWER>`n"
$xml += "<TWID>"+ $_.Version +"</TWID>`n"
$xml += "<VERSION>"+ $_.ClientID +"</VERSION>`n"
$xml += "</TEAMVIEWER>`n"
}
}

# just in case
if($xml -eq $null) {
$xml += "<TEAMVIEWER>`n"
$xml += "<TWID>" + "No data available in table" + "</TWID>`n"
$xml += "<VERSION></VERSION>`n"
$xml += "</TEAMVIEWER>`n"
}

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::WriteLine($xml)
96 changes: 50 additions & 46 deletions agent/Windows/teamviewer.vbs
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
'----------------------------------------------------------
' Plugin for OCS Inventory NG 2.x
' Script : Retrieve Teamviewer ID and version
' Version : 2.00
' Date : 22/07/2017
' Authors : Valentin DEVILLE and Stéphane PAUTREL (acb78.com)
'----------------------------------------------------------
' OS checked [X] on 32b 64b (Professionnal edition)
' Windows XP [X]
' Windows Vista [X] [X]
' Windows 7 [X] [X]
' Windows 8.1 [X] [X]
' Windows 10 [X] [X]
' Windows 2k8R2 [X]
' Windows 2k12R2 [X]
' Windows 2k16 [X]
' ---------------------------------------------------------
' NOTE : No checked on Windows 8
' ---------------------------------------------------------
On Error Resume Next

Set shell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor", , 48 )

For Each objItem in colItems
ArchiOS = objItem.AddressWidth
If ArchiOS = "32" Then
Wow = ""
ElseIf ArchiOS = "64" Then
Wow = "WOW6432Node\"
End If
Next

stReg = "HKEY_LOCAL_MACHINE\SOFTWARE\" & Wow & "TeamViewer\"
Check = shell.RegRead(stReg)
If Err.Number <> 0 Then Wscript.quit

twID = shell.RegRead (stReg & "ClientID")
twVersion = shell.RegRead (stReg & "Version")

Wscript.Echo _
"<TEAMVIEWER>" & VbCrLf &_
"<TWID>" & twID & "</TWID>" & VbCrLf &_
"<VERSION>" & twVersion & "</VERSION>" & VbCrLf &_
"</TEAMVIEWER>"
'----------------------------------------------------------
' Plugin for OCS Inventory NG 2.x
' Script : Retrieve Teamviewer ID and version
' Version : 2.00
' Date : 22/07/2017
' Authors : Valentin DEVILLE and Stéphane PAUTREL (acb78.com)
'----------------------------------------------------------
' OS checked [X] on 32b 64b (Professionnal edition)
' Windows XP [X]
' Windows Vista [X] [X]
' Windows 7 [X] [X]
' Windows 8.1 [X] [X]
' Windows 10 [X] [X]
' Windows 2k8R2 [X]
' Windows 2k12R2 [X]
' Windows 2k16 [X]
' ---------------------------------------------------------
' NOTE : No checked on Windows 8
' ---------------------------------------------------------
On Error Resume Next

Set shell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor", , 48 )

For Each objItem in colItems
ArchiOS = objItem.AddressWidth
If ArchiOS = "32" Then
Wow = ""
ElseIf ArchiOS = "64" Then
Wow = "WOW6432Node\"
End If
Next

stReg = "HKEY_LOCAL_MACHINE\SOFTWARE\" & Wow & "TeamViewer\"
Check = shell.RegRead(stReg)
If Err.Number <> 0 Then Wscript.quit

twID = shell.RegRead (stReg & "ClientID")
twVersion = shell.RegRead (stReg & "Version")

If twID = "" AND twVersion = "" Then
twID = "No data available in table"
End If

Wscript.Echo _
"<TEAMVIEWER>" & VbCrLf &_
"<TWID>" & twID & "</TWID>" & VbCrLf &_
"<VERSION>" & twVersion & "</VERSION>" & VbCrLf &_
"</TEAMVIEWER>"

0 comments on commit 0c3f1ec

Please sign in to comment.