Search For A Solution!

Total Pageviews

Saturday, October 27, 2012

Roll out Teamviewer to Desktops and record ID using Active Directory

As shown at http://technicians-blog.kingcomputer.com.au

So you have sign up to teamviwer and now you need to roll out the client to all desktop within your network.
Well there are a few steps.
Install Teamviewer
Configure
backup Config
Rollout to Clients
Use Script to get Client IDs
See Detail Steps below
1.    Install TeamViewer on one of your machines and configure all options the way you want TeamViewer to run on all machines. Including Password if requied
2.    Open the options dialog (Extras Options) of the configured TeamViewer and switch to the tab Advanced.
Click the button Export at the bottom of this tab to export all options to a .reg file. You can enter your license key during export if you want to deploy your licenses key, too.
3.    Copy all the files of this package and the exported .reg file to a network share. This share has to be accessible by all machines TeamViewer is to be deployed to.
4.    Open the file Install_MSI.vbs using a text editor
Set the value of MSIPATH to the path of the network share (UNC notation required).
Set the value of Install_regfilename32 to the name of your exported .reg file.
If you want to deploy TeamViewer to machines running Windows x64 Editions please create a copy of the exported .reg file and modify the registry paths to fit x64. Set the value of  Install_regfilename64 to the name of this x64 .reg file.
You can modify the filename of the MSI package file if you rather want to install the full version of TeamViewer or TeamViewer Host.
Save and close Install_MS.vbs.
5.    Log on to your domain controller and open the group policy editor.
Create a new group policy and set the file Install_MSI.vbs as startup script.
Rebooting the target machines will execute the installation of TeamViewer using the MSI package.
See Example Script at End.
Now that you have Teamviewer rolled out to your clients you will need IDs.
What I did was use the Teamviewer batch file and add it to the AD group policy that rolls out the Clients.
Script
Save to ListID.bat and ensure computers have access to Disk location
*****
@echo off
FOR /F skip=2 tokens=2* %%i IN (reg query HKLM\System\ControlSet001\Control\Computername\Computername /V Computername) do set Name=%%j
FOR /F skip=2 tokens=2* %%i IN (reg query HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version6 /V ClientID) do set /a LAD=%%j
echo %LAD% > \\server\Disks\Teamviewer\Msi\%name%.txt
****
VBS Script to install Teamviewer
Notice Path to MSIPATH remember \ at end
Const TvModuleName to file name.
Const Regfilename32 name of registry file saved.
********
Option Explicit
Const TeamViewerVersion = 6.0.10344
Dim Shell, FSO, msiPath
Set FSO = CreateObject(Scripting.FileSystemObject)
Set Shell = WScript.CreateObject(WScript.Shell)

DO NOT EDIT ABOVE THIS LINE

msiPath = FSO.GetParentFolderName (WScript.ScriptFullName) & \  Pfad aus Script-Namen extrahieren Get path from script name!
msiPath = \\server\Disks\Teamviewer\Msi\  Pfad zur Netzfreigabe mit MSI-Packet  -   Path to network share containing the MSI files
Const TvModuleName = teamviewer.msi
Const TvModuleName = teamviewer_host.msi
Const Regfilename32  = Teamviewer6.reg  Reg-Datei von TeamViewer für 32-bit Systeme  -  Reg file for TeamViewer on 32-bit systems
Const Regfilename64  = tv-regfile64.reg  Reg-Datei von TeamViewer für 64-bit Systeme  -  Reg file for TeamViewer on 64-bit systems
Const FORCEINSTALLATION = false      TeamViewer immer Installieren/Aktuallisieren -  install or update TeamViewer allways�

DO NOT EDIT BELOW THIS LINE
Dim Install_regfilename32, Install_regfilename64, Install_regfilename, VersionCompare, UninstallRegDir
Install_regfilename32  = chr(34) & msipath & Regfilename32 & chr(34)  Reg-Datei von TeamViewer für 32-bit Systeme  -  Reg file for TeamViewer on 32-bit systems
Install_regfilename64  = chr(34) & msipath & Regfilename64 & chr(34)  Reg-Datei von TeamViewer für 64-bit Systeme  -  Reg file for TeamViewer on 64-bit systems
CheckPlatform           first of all check Plattform!!!
VersionCompare = CheckInstalledTeamViewerVersion  check current installed version
If ((VersionCompare = 1) Or FORCEINSTALLATION) Then
WriteRegistry Install_regfilename  import registry settings
End If
If (VersionCompare = 1) Then
InstallTeamViewer  install newer or very first version
Else
If (VersionCompare = 0 And FORCEINSTALLATION) Then
RepareTeamViewer  reinstall same version
End If
End If
Return Values
-1 eine ältere Version -  Older version
0 Gleiche Version      -  Equal version
1 neuere Version oder nichts installiert.  -  Newer Version or not yet installed
Function CheckInstalledTeamViewerVersion()
Dim objReg, arrSubkeys, strValue, installedVersionNumber, strSubkey, intRet
CheckInstalledTeamViewerVersion = 1  Assume newer version
Const HKLM = &H80000002 HKEY_LOCAL_MACHINE

Set objReg = GetObject(winmgmts://./root/default:StdRegProv)  �
objReg.EnumKey HKLM, UninstallRegDir, arrSubkeys
For Each strSubkey In arrSubkeys
intRet = objReg.GetStringValue(HKLM, UninstallRegDir & strSubkey, DisplayName, strValue)      �
If (intRet = 0) Then
If strValue = TeamViewer 6 (MSI Wrapper) Or strValue = TeamViewer 6 Host (MSI Wrapper) Then
objReg.GetStringValue HKLM, UninstallRegDir & strSubkey, DisplayVersion, InstalledVersionNumber
MsgBox(InstalledVersionNumber)
If ( cint(Mid(TEAMVIEWERVERSION,5,Len(TEAMVIEWERVERSION)-4)) < cint(Mid(installedVersionNumber,5,Len(InstalledVersionNumber)-4)) ) Then
CheckInstalledTeamViewerVersion = -1 older version   �
End If
If ( cint(Mid(TEAMVIEWERVERSION,5,Len(TEAMVIEWERVERSION)-4)) = cint(Mid(installedVersionNumber,5,Len(InstalledVersionNumber)-4)) ) Then
CheckInstalledTeamViewerVersion = 0  equal verion       �
End If
End If
End If  �
Next
End Function
Überprüfung der aktuellen Plattform
Function CheckPlatform()
Dim regCheck, platform

RegCheck = shell.regread(HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE)
x86
platform=InStr(RegCheck,86)
If platform >= 1 Then
Install_regfilename = Install_regfilename32
UninstallRegDir = SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
End If

x64
platform=InStr(RegCheck,64)
If platform >= 1 Then
Install_regfilename = Install_regfilename64
UninstallRegDir = SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
End If
End Function
Schreiben der TeamViewer Registry-Keys
Function WriteRegistry(regfilename)
Shell.Run regedit /s & regfilename, 0,True
End Function
Function InstallTeamViewer()
MsgBox(Install)
Shell.Run msiexec.exe /i & chr(34) & msiPath & TvModuleName & chr(34) & /quiet, 0,True
End Function
Function RepareTeamViewer()
MsgBox(Repair)
Shell.Run msiexec.exe /fa & chr(34) & msiPath & TvModuleName & chr(34) & /quiet, 0,True
Shell.Run msiexec.exe /i & chr(34) & msiPath & TvModuleName & chr(34) & /quiet REINSTALL=ALL REBOOT=ReallySuppress, 0,True
End Function
*****

You can also compare above to below in WinMerge

Visual Basic-Quellcode

  1. Option Explicit
  2. Const TeamViewerVersion = "6.0.10194"
  3. Dim Shell, FSO, msiPath
  4. Set FSO = CreateObject("Scripting.FileSystemObject")
  5. Set Shell = WScript.CreateObject("WScript.Shell")
  6. ''''
  7. '''''''''''' DO NOT EDIT ABOVE THIS LINE ''''''''''''
  8. ''''
  9. 'msiPath = FSO.GetParentFolderName (WScript.ScriptFullName) & "\" 'Pfad aus Script-Namen extrahieren - Get path from script name!
  10. msiPath = "\\SERV14\SoftwareVerteilung\TeamViewerHost\" 'Pfad zur Netzfreigabe mit MSI-Packet - Path to network share containing the MSI files
  11. 'Const TvModuleName = "teamviewer.msi"
  12. Const TvModuleName = "teamviewer_host.msi"
  13. Const Regfilename32 = "tv-regfile32.reg" 'Reg-Datei von TeamViewer für 32-bit Systeme - Reg file for TeamViewer on 32-bit systems
  14. Const Regfilename64 = "tv-regfile64.reg" 'Reg-Datei von TeamViewer für 64-bit Systeme - Reg file for TeamViewer on 64-bit systems
  15. Const FORCEINSTALLATION = false 'TeamViewer immer Installieren/Aktuallisieren - install or update TeamViewer allways
  16. ''''
  17. '''''''''''' DO NOT EDIT BELOW THIS LINE ''''''''''''
  18. ''''
  19. Dim Install_regfilename32, Install_regfilename64, Install_regfilename, VersionCompare, UninstallRegDir
  20. Install_regfilename32 = chr(34) & msipath & Regfilename32 & chr(34) 'Reg-Datei von TeamViewer für 32-bit Systeme - Reg file for TeamViewer on 32-bit systems
  21. Install_regfilename64 = chr(34) & msipath & Regfilename64 & chr(34) 'Reg-Datei von TeamViewer für 64-bit Systeme - Reg file for TeamViewer on 64-bit systems
  22. CheckPlatform ' first of all check Plattform!!!
  23. VersionCompare = CheckInstalledTeamViewerVersion ' check current installed version
  24. If ((VersionCompare = 1) Or FORCEINSTALLATION) Then
  25. WriteRegistry Install_regfilename ' import registry settings
  26. End If
  27. If (VersionCompare = 1) Then
  28. InstallTeamViewer ' install newer or very first version
  29. Else
  30. If (VersionCompare = 0 And FORCEINSTALLATION) Then
  31. RepareTeamViewer ' reinstall same version
  32. End If
  33. End If
  34. ' Return Values
  35. ' -1 eine ältere Version - Older version
  36. ' 0 Gleiche Version - Equal version
  37. ' 1 neuere Version oder nichts installiert. - Newer Version or not yet installed
  38. Function CheckInstalledTeamViewerVersion()
  39. Dim objReg, arrSubkeys, strValue, installedVersionNumber, strSubkey, intRet
  40. CheckInstalledTeamViewerVersion = 1 'Assume newer version
  41. Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
  42. Set objReg = GetObject("winmgmts://./root/default:StdRegProv")
  43. objReg.EnumKey HKLM, UninstallRegDir, arrSubkeys
  44. For Each strSubkey In arrSubkeys
  45. intRet = objReg.GetStringValue(HKLM, UninstallRegDir & strSubkey, "DisplayName", strValue)
  46. If (intRet = 0) Then
  47. If strValue = "TeamViewer 6 (MSI Wrapper)" Or strValue = "TeamViewer 6 Host (MSI Wrapper)" Then
  48. objReg.GetStringValue HKLM, UninstallRegDir & strSubkey, "DisplayVersion", InstalledVersionNumber
  49. 'MsgBox(InstalledVersionNumber)
  50. If ( cint(Mid(TEAMVIEWERVERSION,5,Len(TEAMVIEWERVERSION)-4)) < cint(Mid(installedVersionNumber,5,Len(InstalledVersionNumber)-4)) ) Then
  51. CheckInstalledTeamViewerVersion = -1 'older version
  52. End If
  53. If ( cint(Mid(TEAMVIEWERVERSION,5,Len(TEAMVIEWERVERSION)-4)) = cint(Mid(installedVersionNumber,5,Len(InstalledVersionNumber)-4)) ) Then
  54. CheckInstalledTeamViewerVersion = 0 'equal verion
  55. End If
  56. End If
  57. End If
  58. Next
  59. End Function
  60. 'Überprüfung der aktuellen Plattform
  61. Function CheckPlatform()
  62. Dim regCheck, platform
  63. RegCheck = shell.regread("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
  64. 'x86
  65. platform=InStr(RegCheck,"86")
  66. If platform >= 1 Then
  67. Install_regfilename = Install_regfilename32
  68. UninstallRegDir = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
  69. End If
  70. 'x64
  71. platform=InStr(RegCheck,"64")
  72. If platform >= 1 Then
  73. Install_regfilename = Install_regfilename64
  74. UninstallRegDir = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
  75. End If
  76. End Function
  77. 'Schreiben der TeamViewer Registry-Keys
  78. Function WriteRegistry(regfilename)
  79. Shell.Run "regedit /s " & regfilename, 0,True
  80. End Function
  81. Function InstallTeamViewer()
  82. MsgBox("Install")
  83. Shell.Run "msiexec.exe /i " & chr(34) & msiPath & TvModuleName & chr(34) & " /quiet", 0,True
  84. End Function
  85. Function RepareTeamViewer()
  86. 'MsgBox("Repair")
  87. 'Shell.Run "msiexec.exe /fa " & chr(34) & msiPath & TvModuleName & chr(34) & " /quiet", 0,True
  88. Shell.Run "msiexec.exe /i " & chr(34) & msiPath & TvModuleName & chr(34) & " /quiet REINSTALL=ALL REBOOT=ReallySuppress", 0,True
  89. End Function

No comments:

Post a Comment