Hello,
I wrote a simple vbs script to get the field from sql database and then pass it to a custom action to work with teamviewer
needed: teamviewer.vbs , teamviewer.exe
Save teamviewer.exe in the action folder as configured in {actionpath}
Save teamviewer.vbs in the same folder.
teamviewer.vbs
call Init
Public Sub Init
Dim rstAuthors, teamviewerid, shell
if isobject(cn) = false then
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.ConnectionString = "Provider=SQLOLEDB.1;Data " & _
"Source=sourcedatabase; Initial Catalog=lansweeperdb;user id = " & _
"'sa';password='yourpassword'"
cn.Open
strAuthorsQry = "Select tblCompCustom.Custom1 From tblComputers Inner Join tblCompCustom On tblComputers.Computername = tblCompCustom.Computername Where (tblcomputers.domain = '" & wscript.arguments(0) & "' AND tblcomputers.computer = '" & wscript.arguments(1) & "')"
set rstAuthors = cn.execute(strAuthorsQry)
rstAuthors.MoveFirst
teamviewerid = rstauthors("Custom1")
Set shell = CreateObject("WScript.Shell")
shell.Run "\\pathtoactionsfolder\teamviewer.exe -i " & teamviewerid & "", 1, false
Set shell = Nothing
end if
End Sub
then create a computer custom action
{actionpath}teamviewer.vbs {domain} {computer}
In this case I used domain and computer but you can use another parameter of your choice.
This worked for me, if you have any question please post and I will help as possible.
Remember to change the details of the connection/query with your environment parameters.
Alexandre.