cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JTempleton
Engaged Sweeper III
Is it possible to setup a custom action to launch and connect TeamViewer? I know the command line options, but how can I get the registry options into a custom action?
1 ACCEPTED SOLUTION
Hendrik_VE
Champion Sweeper III
Hi all,

I managed to create a custom TeamViewer action using this small workaround (currently only for 64 bit TeamViewer clients, but can easily be expanded to support 32 bit TV or older TV versions too, using the registry keys mentioned earlier in this topic):

1. Set up registry scanning for the registry value 'ClientID' from SOFTWARE\WOW6432Node\TeamViewer

2. Create a custom report that exports the hostname and TeamViewer ClientID to a CSV file called 'TeamViewer_DeviceID.csv':
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblRegistry.Value
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblRegistry On tblAssets.AssetID = tblRegistry.AssetID
Where tblAssetCustom.State = 1 And tblRegistry.Valuename = 'ClientID'


3. Add a custom action called 'TeamViewer' which runs the following action:
powershell -noprofile -executionpolicy bypass -command {actionpath}tv.ps1 {computer}

4. In the Actions folder of your Lansweeper server, add the powershell script 'tv.ps1' which contains the following commands:
$server = $args[0]
$ARG = import-csv "\\<LansweeperServer>\export\TeamViewer_DeviceID.csv" -Delimiter ';' |where-object assetname -like $server | select value -ExpandProperty value
start-process -filepath "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" -argumentlist "-i $ARG"


5. See the magic happen when clicking on the TeamViewer action.

View solution in original post

26 REPLIES 26
drobertson
Engaged Sweeper III
Works with TeamViewer QS and TeamViewer Full Version -

First setup registry scanning on the following keys for the RegValue of "ClientID":
HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version6
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version7
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version8
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version9
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version10
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version11
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version12


Then instead of using the CSV method described above, I just query the database directly in powershell and use this asset action in lansweeper:


powershell -noprofile -executionpolicy bypass -command {actionpath}TV.ps1 {assetid}


I just have it scan my registry for the TV client IDs and then my TV.ps1 script in the Actions folder looks like this:



# lansweeper db connection details
$mssql_server_instance = "YOUR_DETAILS_HERE"
$mssql_databasename = "YOUR_DETAILS_HERE"
$ms_uid = "YOUR_DETAILS_HERE"
$ms_pwd = "YOUR_DETAILS_HERE"

function GetTeamViewerClientID {
param(
[Parameter(Mandatory = $true)][String] $ms_uid,
[Parameter(Mandatory = $true)][String] $ms_pwd,
[Parameter(Mandatory = $true)][String] $mssql_server_instance,
[Parameter(Mandatory = $true)][String] $mssql_databasename,
[Parameter(Mandatory = $true)][String] $LS_AssetID
)
$dbquery = "SELECT Value FROM lansweeperdb.dbo.tblRegistry WHERE AssetID='"+$LS_AssetID+"' AND Valuename = 'ClientID'"
$connectionString = 'Data Source={0};database={1};User ID={2};Password={3}' -f $mssql_server_instance,$mssql_databasename,$ms_uid,$ms_pwd
$connection = New-Object System.Data.SqlClient.SqlConnection $connectionString
$connection.ConnectionString = $connectionString
$command = New-Object System.Data.SqlClient.SqlCommand
$command.CommandText = $dbquery
$command.Connection = $connection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $command
$DataSet = New-Object System.Data.DataSet
$EXECUTE_QUERY = $SqlAdapter.Fill($DataSet)
$connection.Close()
foreach ($Row in $DataSet.Tables[0].Rows)
{
$tv_clientid = $Row.Value
}
return $tv_clientid
}

$LS_AssetID = $args[0]
$ARG = GetTeamViewerClientID $ms_uid $ms_pwd $mssql_server_instance $mssql_databasename $LS_AssetID
start-process -filepath "C:\Program Files\TeamViewer\TeamViewer.exe" -argumentlist "-i $ARG"



Be sure to edit the TV.ps1 script with your own lansweeper database connection details.
marck1024
Engaged Sweeper III
Very nice solution! Thanks for sharing.
CyberCitizen
Honored Sweeper
I am also using v14 but it is working for me.
Hendrik_VE
Champion Sweeper III
Hi all,

I managed to create a custom TeamViewer action using this small workaround (currently only for 64 bit TeamViewer clients, but can easily be expanded to support 32 bit TV or older TV versions too, using the registry keys mentioned earlier in this topic):

1. Set up registry scanning for the registry value 'ClientID' from SOFTWARE\WOW6432Node\TeamViewer

2. Create a custom report that exports the hostname and TeamViewer ClientID to a CSV file called 'TeamViewer_DeviceID.csv':
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblRegistry.Value
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblRegistry On tblAssets.AssetID = tblRegistry.AssetID
Where tblAssetCustom.State = 1 And tblRegistry.Valuename = 'ClientID'


3. Add a custom action called 'TeamViewer' which runs the following action:
powershell -noprofile -executionpolicy bypass -command {actionpath}tv.ps1 {computer}

4. In the Actions folder of your Lansweeper server, add the powershell script 'tv.ps1' which contains the following commands:
$server = $args[0]
$ARG = import-csv "\\<LansweeperServer>\export\TeamViewer_DeviceID.csv" -Delimiter ';' |where-object assetname -like $server | select value -ExpandProperty value
start-process -filepath "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" -argumentlist "-i $ARG"


5. See the magic happen when clicking on the TeamViewer action.
Hendrik.VE wrote:
Hi all,

I managed to create a custom TeamViewer action using this small workaround (currently only for 64 bit TeamViewer clients, but can easily be expanded to support 32 bit TV or older TV versions too, using the registry keys mentioned earlier in this topic):

1. Set up registry scanning for the registry value 'ClientID' from SOFTWARE\WOW6432Node\TeamViewer

2. Create a custom report that exports the hostname and TeamViewer ClientID to a CSV file called 'TeamViewer_DeviceID.csv':
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblRegistry.Value
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblRegistry On tblAssets.AssetID = tblRegistry.AssetID
Where tblAssetCustom.State = 1 And tblRegistry.Valuename = 'ClientID'


3. Add a custom action called 'TeamViewer' which runs the following action:
powershell -noprofile -executionpolicy bypass -command {actionpath}tv.ps1 {computer}

4. In the Actions folder of your Lansweeper server, add the powershell script 'tv.ps1' which contains the following commands:
$server = $args[0]
$ARG = import-csv "\\<LansweeperServer>\export\TeamViewer_DeviceID.csv" -Delimiter ';' |where-object assetname -like $server | select value -ExpandProperty value
start-process -filepath "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" -argumentlist "-i $ARG"


5. See the magic happen when clicking on the TeamViewer action.


I have followed your steps but I get this error message:

"Error parsing commandline:the required argument for option '--id' is missing"
Hendrik.VE wrote:
Hi all,

I managed to create a custom TeamViewer action using this small workaround (currently only for 64 bit TeamViewer clients, but can easily be expanded to support 32 bit TV or older TV versions too, using the registry keys mentioned earlier in this topic):

1. Set up registry scanning for the registry value 'ClientID' from SOFTWARE\WOW6432Node\TeamViewer

2. Create a custom report that exports the hostname and TeamViewer ClientID to a CSV file called 'TeamViewer_DeviceID.csv':
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblRegistry.Value
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblRegistry On tblAssets.AssetID = tblRegistry.AssetID
Where tblAssetCustom.State = 1 And tblRegistry.Valuename = 'ClientID'


3. Add a custom action called 'TeamViewer' which runs the following action:
powershell -noprofile -executionpolicy bypass -command {actionpath}tv.ps1 {computer}

4. In the Actions folder of your Lansweeper server, add the powershell script 'tv.ps1' which contains the following commands:
$server = $args[0]
$ARG = import-csv "\\<LansweeperServer>\export\TeamViewer_DeviceID.csv" -Delimiter ';' |where-object assetname -like $server | select value -ExpandProperty value
start-process -filepath "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" -argumentlist "-i $ARG"


5. See the magic happen when clicking on the TeamViewer action.


I followed the instructions but all that happens for me is that TV will flash and open but it will not change the ClientID in TV. I am running TV14 Commercial (some users use the host module). Has something changed since ver. 12 when this was last posted?
Hendrik.VE wrote:
Hi all,

I managed to create a custom TeamViewer action using this small workaround (currently only for 64 bit TeamViewer clients, but can easily be expanded to support 32 bit TV or older TV versions too, using the registry keys mentioned earlier in this topic):

1. Set up registry scanning for the registry value 'ClientID' from SOFTWARE\WOW6432Node\TeamViewer

2. Create a custom report that exports the hostname and TeamViewer ClientID to a CSV file called 'TeamViewer_DeviceID.csv':
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblRegistry.Value
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblRegistry On tblAssets.AssetID = tblRegistry.AssetID
Where tblAssetCustom.State = 1 And tblRegistry.Valuename = 'ClientID'


3. Add a custom action called 'TeamViewer' which runs the following action:
powershell -noprofile -executionpolicy bypass -command {actionpath}tv.ps1 {computer}

4. In the Actions folder of your Lansweeper server, add the powershell script 'tv.ps1' which contains the following commands:
$server = $args[0]
$ARG = import-csv "\\<LansweeperServer>\export\TeamViewer_DeviceID.csv" -Delimiter ';' |where-object assetname -like $server | select value -ExpandProperty value
start-process -filepath "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" -argumentlist "-i $ARG"


5. See the magic happen when clicking on the TeamViewer action.


I presume this wouldn't work for client PCs that only run the TeamViewer QS standalone, correct, but only if it is the local installed (freeware or licensed) client?
Hendrik_VE
Champion Sweeper III
Cripple.Zero wrote:

I presume this wouldn't work for client PCs that only run the TeamViewer QS standalone, correct, but only if it is the local installed (freeware or licensed) client?


I haven't tried it myself, but I don't think it will work as TeamViewer QS probably doesn't write anything in the DB.
You will have to enter the TV ID manually.
marck1024
Engaged Sweeper III
Still hoping Lansweeper will gain the ability to reference custom fields in actions.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now