{"id":220,"date":"2008-12-03T01:57:32","date_gmt":"2008-12-02T17:57:32","guid":{"rendered":"http:\/\/www.jhouseconsulting.com\/?p=220"},"modified":"2010-10-19T10:36:42","modified_gmt":"2010-10-19T02:36:42","slug":"the-bees-knees-script-for-installing-vmware-tools","status":"publish","type":"post","link":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/2008\/12\/03\/the-bees-knees-script-for-installing-vmware-tools-220","title":{"rendered":"The Bees Knees script for installing VMware Tools"},"content":{"rendered":"<p>Updated 19th October 2010&#8230;<\/p>\n<p>This is what I call the &#8220;bees knees&#8221; of scripts for deploying VMware Tools. It will detect if it&#8217;s being installed on a Terminal\/Citrix Server, and remove the appropriate components that may impede performance, etc.<!--more--><\/p>\n<p>I was initially using an old well know script to set the video acceleration. However, my friend <a href=\"http:\/\/theether.net\/\" target=\"_blank\">Jamie Morrison<\/a>, has written an even better one, which I&#8217;ve included as a function within this script. I also found a really nice PowerShell script for <a href=\"http:\/\/www.peetersonline.nl\/index.php\/vmware\/setting-video-hardware-acceleration-level\/\" target=\"_blank\">Setting Video Hardware Acceleration Level<\/a>.<\/p>\n<p>One of the tasks performed by the installation of VMware Tools is that it replaces the &#8220;Standard VGA Graphics Adapter&#8221; driver with the &#8220;VMware SVGA II&#8221; driver. It then detects if the Hardware Acceleration has previously been set to Full. If it hasn&#8217;t, it&#8217;ll prompt you with the following message box even if you are using the \/qb (quiet with a basic user interface) MSIEXEC switch.<\/p>\n<p><a href=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2008\/12\/promptforsettinghardwareacceleration.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-238\" title=\"promptforsettinghardwareacceleration\" src=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2008\/12\/promptforsettinghardwareacceleration.png\" alt=\"\" width=\"489\" height=\"125\" srcset=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2008\/12\/promptforsettinghardwareacceleration.png 489w, https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2008\/12\/promptforsettinghardwareacceleration-300x77.png 300w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/a><\/p>\n<p>On the other hand using the \/qn switch disables the VM_CheckHWAcceleration action altogether. However, I try to avoid using the \/qn switch for these sorts of things, as then you can&#8217;t see what&#8217;s going on when monitoring it from the console, etc.<\/p>\n<p>So the trick is to set the Hardware Acceleration to Full before installing VMware Tools. Then, when it runs the detection mechanism by calling the VM_CheckHWAcceleration action within the MSI package, it will read back that it has already been set and complete the silent installation without any prompts.<\/p>\n<p>Place the below InstallVMwareTools.vbs script in a folder, extracting the VMware Tools iso into a subfolder called &#8220;VMware Tools&#8221;.<\/p>\n<p>Note that the only line in the script you may want to change is the <strong>strLogLocation<\/strong> definition, which sets the location of the MSI log file. As you can see I place it in the &#8220;%SystemDrive%\\bldlogs&#8221; folder.<\/p>\n<p>Enjoy!!!<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VMware Tools installation script.\r\n\r\n' For Citrix\/Terminal\/RDS Servers, don't install VMware Tools components that can impede\r\n' performance. These include: \r\n' - MemCtl - Memory Control Driver (vmmemctl \u2013 reclaims memory using the balloon driver) \r\n' - vmdesched - Descheduled Time Accounting (experimental) \r\n' - Sync - Filesystem Sync Driver (LGTO_SYNC - can halt I\/O disrupting services\/users) \r\n' - Hgfs - Shared Folders (vmhgfs \u2013 not supported on ESX) \r\n\r\n' There is now evidence to suggest that under ESX4.x and certain deployment scenarios\r\n' leaving the memory control driver enabled can assist with performance. Discussions with\r\n' VMware suggest that it will only be used when the host is under memory pressure and will\r\n' intelligently select memory to balloon in conjunction with the operating system. The\r\n' alternative is the host paging out virtual machine memory to disk, which may be highly\r\n' active, possibly suspending a virtual machine for milliseconds at a time. This situation\r\n' should not arise if suitable resources are available, but an unexpected event such as a\r\n' host failure may cause this. Therefore, a boolean value of blnRemoveMemoryBaloonDriver\r\n' has been added that can be set to True or False depending on your requirements.\r\n\r\n' Before we proceed we first need to check that the &quot;Terminal Services&quot; (TermServ) service\r\n' is running, otherwise using the WMI provider to query the Win32_TerminalServiceSetting\r\n' properties will return a null value. Note that the WMI provider namespace is slighly\r\n' different between Windows 2003 and Windows 2008.\r\n\r\n' Reference for Unattended Installation of VMware Tools in Windows:\r\n' http:\/\/communities.vmware.com\/servlet\/JiveServlet\/downloadBody\/12413-102-4-13370\/VMware%20Tools%20-%20Unattended_Install.pdf\r\n\r\n' The setVideoAcceleration function was written by Jamie Morrison (http:\/\/theether.net\/)\r\n\r\n' It's expecting the latest version of VMware Tools to be extracted into a subfolder called\r\n' &quot;VMware Tools&quot;. So your folder structure will look like this...\r\n' - InstallVMwareTools.vbs (this script)\r\n' - VMware Tools (this is a folder that contains the extracted VMware Tools)\r\n\r\n' Version 1.6 released on 19th October 2010.\r\n' Written by Jeremy@jhouseconsulting.com on 1st December 2008.\r\n\r\nOption Explicit\r\n\r\nDim objFSO, objFolder, wshShell, oShellLink, strScriptPath, strLogLocation, strOS\r\nDim strOptions, strCommandLine, strRegKey, blnDeleteVMwareUserProcess, blnReturn\r\nDim strProcessorArchitecture, strMSI, blnNewInstall, blnRemoveMemoryBaloonDriver\r\nDim strvalue, blnMoveStartMenuFolder, strITToolsFolder, strAllUsersProfile\r\nDim strLogFile, strFrom, strTo\r\n\r\n'********** These are the script variables that can be changed **********\r\n\r\n' Setting this to false will not remove the VMware memory balloon driver.\r\nblnRemoveMemoryBaloonDriver = False\r\n\r\n' Removing the &quot;VMware User Process&quot; (VMwareUser.exe) from the Run key causes no detrement\r\n' to the running Guest. It may cause some loss of functionality from VMware Tools e.g. Drag\r\n' and drop\/copy and paste operations which does not seem to affect ICA sessions. Change this\r\n' value to False if you do not want to disable the VMwareUser.exe process.\r\nblnDeleteVMwareUserProcess = True\r\n\r\n' Setting this to true will move the VMware Start Menu folder to the Start Menu subfolder\r\n' defined.\r\nblnMoveStartMenuFolder = True\r\nstrITToolsFolder = &quot;IT Tools&quot;\r\n\r\n' Set the log file location\r\nstrLogLocation = &quot;%SystemDrive%\\bldlogs&quot;\r\n\r\n' Set the log file name\r\nstrLogFile = &quot;VMwareTools.Log&quot;\r\n\r\n'************************************************************************\r\n\r\nset WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)\r\nset objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n\r\nstrLogLocation = WshShell.ExpandEnvironmentStrings(strLogLocation)\r\n\r\nstrScriptPath = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, &quot;\\&quot;))\r\n\r\n' Create the log file folder\r\nIf NOT objFSO.FolderExists(strLogLocation) Then\r\n  objFSO.CreateFolder(strLogLocation)\r\nEnd If\r\n\r\nstrProcessorArchitecture = WshShell.ExpandEnvironmentStrings(&quot;%PROCESSOR_ARCHITECTURE%&quot;)\r\nstrAllUsersProfile = WshShell.ExpandEnvironmentStrings(&quot;%ALLUSERSPROFILE%&quot;)\r\n\r\nstrOS = GetOSFamily()\r\n\r\n' Modifying the video hardware acceleration\r\nIf setVideoAcceleration Then\r\n    wscript.echo &quot;Updated Video Hardware Acceleration to Full.&quot;\r\nElse\r\n    wscript.echo &quot;No Video Hardware Acceleration to set.&quot;\r\nEnd If\r\n\r\n' Detect previous installation of VMware Tools\r\nblnNewInstall = True\r\nstrvalue = &quot;HKLM\\SYSTEM\\CurrentControlSet\\Services\\VMTools\\Start&quot;\r\nIf RegValueExists(strvalue) Then\r\n  blnNewInstall = False\r\nEnd If\r\n\r\n' Building the MSIEXEC command line options\r\nIf blnNewInstall Then\r\n  strOptions = &quot; ALLUSERS=TRUE ADDLOCAL=ALL \/Lv* &quot; &amp; chr(34) &amp; strLogLocation &amp; &quot;\\&quot; &amp; strLogFile &amp; chr(34) &amp; &quot; \/qb- REBOOT=ReallySuppress&quot;\r\nElse\r\n  strOptions = &quot; ALLUSERS=TRUE \/Lv* &quot; &amp; chr(34) &amp; strLogLocation &amp; &quot;\\&quot; &amp; strLogFile &amp; chr(34) &amp; &quot; \/qb- REBOOT=ReallySuppress&quot;\r\nEnd If\r\nIf isTerminalServer(strOS) Then\r\n  If blnRemoveMemoryBaloonDriver Then\r\n    strOptions = strOptions &amp; &quot; REMOVE=&quot; &amp; chr(34) &amp; &quot;Hgfs,MemCtl,Sync,vmdesched&quot; &amp; chr(34)\r\n  Else\r\n    strOptions = strOptions &amp; &quot; REMOVE=&quot; &amp; chr(34) &amp; &quot;Hgfs,Sync,vmdesched&quot; &amp; chr(34)\r\n  End If\r\nEnd If\r\n\r\nIf strProcessorArchitecture = &quot;x86&quot; Then\r\n  strMSI = &quot;VMware Tools.msi&quot;\r\nElse\r\n  strMSI = &quot;VMware Tools64.msi&quot;\r\nEnd If\r\n\r\n' Installing VMware Tools with the relevant command line options\r\nstrCommandLine = &quot;msiexec \/i &quot; &amp; chr(34) &amp; strScriptPath &amp; &quot;VMware Tools\\&quot;&amp; strMSI &amp; chr(34) &amp; strOptions\r\nWshShell.Run strCommandLine,1,True\r\n\r\n' If we are building a Citrix\/Terminal Server, delete VMware Tools Tray Icon and VMware User\r\n' Process from the Run key. The VMware User Process will only be removed if\r\n' blnDeleteVMwareUserProcess is set to True. There are settings for this in our Group Policy\r\n' ADM template. It will also move the Start Menu Folder to a location specified by the\r\n' strITToolsFolder variable.\r\nIf isTerminalServer(strOS) Then\r\n  strRegKey = &quot;HKLM\\SOFTWARE\\VMware, Inc.\\VMware Tools\\&quot;\r\n  If RegValueExists(strRegKey &amp; &quot;ShowTray&quot;) Then\r\n    WshShell.RegWrite strRegKey &amp; &quot;ShowTray&quot;, &quot;0&quot;, &quot;REG_DWORD&quot;\r\n    wscript.echo &quot;VMware Tools Tray Icon has been disabled.&quot;\r\n  End If\r\n  strRegKey = &quot;HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\&quot;\r\n  If RegValueExists(strRegKey &amp; &quot;VMware Tools&quot;) Then\r\n    WshShell.RegDelete strRegKey &amp; &quot;VMware Tools&quot;\r\n    wscript.echo &quot;VMware Tools registry value deleted.&quot;\r\n  Else\r\n    wscript.echo &quot;VMware Tools registry value does not exist.&quot;\r\n  End If\r\n  If blnDeleteVMwareUserProcess Then\r\n    If RegValueExists(strRegKey &amp; &quot;VMware User Process&quot;) Then\r\n      WshShell.RegDelete strRegKey &amp; &quot;VMware User Process&quot;\r\n      wscript.echo &quot;VMware User Process registry value deleted.&quot;\r\n    Else\r\n      wscript.echo &quot;VMware User Process registry value does not exist.&quot;\r\n    End If\r\n  End If\r\n' Move the Start Menu Folder.\r\n  If blnMoveStartMenuFolder Then\r\n    If NOT objFSO.FolderExists(strAllUsersProfile &amp; &quot;\\Start Menu\\Programs\\&quot; &amp; strITToolsFolder) Then\r\n      objFSO.CreateFolder(strAllUsersProfile &amp; &quot;\\Start Menu\\Programs\\&quot; &amp; strITToolsFolder)\r\n    End If\r\n    strFrom = strAllUsersProfile &amp; &quot;\\Start Menu\\Programs\\VMware&quot;\r\n    strTo = strAllUsersProfile &amp; &quot;\\Start Menu\\Programs\\&quot; &amp; strITToolsFolder &amp; &quot;\\&quot;\r\n    Call MoveFolder(strFrom,strTo)\r\n    wscript.echo &quot;VMware Start Menu Folder has been moved.&quot;\r\n  End If\r\nEnd If\r\n\r\nSet WshShell = Nothing\r\nset objFSO = Nothing\r\n\r\nWScript.Quit(0)\r\n\r\nFunction setVideoAcceleration()\r\n'\r\n' SYNTAX:\t\tsetVideoAcceleration()\r\n'\t\t\r\n' Parameters:\tN\/A\r\n'\r\n' Returns:\t\tTrue if registry written successfully\r\n'\r\n' Example:\t\tsetVideoAcceleration\r\n'\r\n' Remarks:\t\t\r\n'\r\n  Const HKEY_LOCAL_MACHINE = &amp;H80000002\r\n  Const VIDEO_LIST = &quot;SYSTEM\\CurrentControlSet\\Control\\Video&quot;\r\n\r\n  Dim   wbemLocator, wbemDefault, wshShell, regAllWMI, adapterList, adapterGUID, adapterPath, dwValue\r\n\r\n  Set wbemLocator = CreateObject(&quot;WbemScripting.SWbemLocator&quot;)\r\n  Set wbemDefault = wbemLocator.ConnectServer(&quot;.&quot;, &quot;root\\default&quot;)\r\n  Set wshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)\r\n\r\n  setVideoAcceleration = False\r\n  Set regAllWMI = wbemDefault.Get(&quot;StdRegProv&quot;)\r\n  If (Err.Number &lt;&gt; 0) Then\r\n    wscript.echo &quot;Error connecting to WMI StdRegProv &quot; &amp; Err.Number &amp; &quot; : &quot; &amp; Err.Description\r\n  Else\r\n    regAllWMI.EnumKey HKEY_LOCAL_MACHINE, VIDEO_LIST, adapterList\r\n    If (Err.Number &lt;&gt; 0) Then\r\n      wscript.echo &quot;Could not enumerate video adapters&quot;\r\n    Else\r\n      For Each adapterGUID In adapterList\r\n        adapterPath = VIDEO_LIST &amp; &quot;\\&quot; &amp; adapterGUID &amp; &quot;&#92;&#48;000&quot;\r\n        regAllWMI.GetDWORDValue HKEY_LOCAL_MACHINE, adapterPath, &quot;Acceleration.Level&quot;, dwValue\r\n        If Not IsNull(dwValue) Then\r\n          regAllWMI.SetDWORDValue HKEY_LOCAL_MACHINE, adapterPath, &quot;Acceleration.Level&quot;, 0\r\n          setVideoAcceleration = True\r\n        End If\r\n      Next\r\n    End If\r\n  End If\r\n  Set regAllWMI = Nothing\r\n  Set wshShell = Nothing\r\n  Set wbemDefault = Nothing\r\n  Set wbemLocator = Nothing\r\n\r\nEnd Function\r\n\r\nFunction RegValueExists(sRegValue)\r\n' Returns True or False based of the existence of a registry value.\r\n  Dim oShell, RegReadReturn \r\n  Set oShell = CreateObject(&quot;WScript.Shell&quot;) \r\n  RegValueExists = True  ' init value \r\n  On Error Resume Next \r\n  RegReadReturn = oShell.RegRead(sRegValue) \r\n  If Err.Number &lt;&gt; 0 Then \r\n    RegValueExists = False \r\n  End if \r\n  On Error Goto 0 \r\n  Set oShell = Nothing\r\nEnd Function \r\n\r\nSub MoveFolder(strFrom, strTo)\r\n  Dim objFSO\r\n  Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n  If NOT objFSO.FolderExists(strTo) Then\r\n    Set objFolder = objFSO.CreateFolder(strTo)\r\n  End If\r\n  If objFSO.FolderExists(strFrom) Then\r\n    objFSO.CopyFolder strFrom , strTo , True\r\n    objFSO.DeleteFolder(strFrom)\r\n  End If\r\n  Set objFSO = Nothing\r\n  Set objFolder = Nothing\r\nEnd Sub\r\n\r\nFunction GetOSFamily()\r\n  Dim strComputer, oWMIService, colOSInfo, oOSProperty, strCaption, strOSFamily\r\n  strComputer = &quot;.&quot;\r\n  Set oWMIService = GetObject(&quot;winmgmts:\\\\&quot; &amp; strComputer &amp; &quot;\\root\\cimv2&quot;)\r\n  Set colOSInfo = oWMIService.ExecQuery(&quot;Select * from Win32_OperatingSystem&quot;)\r\n  For Each oOSProperty in colOSInfo\r\n    strCaption = oOSProperty.Caption\r\n  Next\r\n  If InStr(1,strCaption, &quot;2008&quot;, vbTextCompare) Then strOSFamily = &quot;W2K8&quot;\r\n  If InStr(1,strCaption, &quot;2003&quot;, vbTextCompare) Then strOSFamily = &quot;W2K3&quot;\r\n  GetOSFamily = strOSFamily\r\n  Set oWMIService = Nothing\r\n  Set colOSInfo = Nothing\r\nEnd Function\r\n\r\nFunction isTerminalServer(strOS)\r\n  Dim strComputer, strNameSpace, objWMIService, colItems, objItem   \r\n  strComputer = &quot;.&quot;\r\n  If ucase(strOS) = &quot;W2K3&quot; Then\r\n    strNameSpace = &quot;\\root\\cimv2&quot;\r\n  Else\r\n    strNameSpace = &quot;\\root\\cimv2\\TerminalServices&quot;\r\n  End If\r\n  Set objWMIService = GetObject(&quot;winmgmts:&quot; _   \r\n    &amp; &quot;{impersonationLevel=impersonate}!\\\\&quot; &amp; strComputer &amp; strNameSpace)  \r\n  Set colItems = objWMIService.ExecQuery _  \r\n    (&quot;Select * from Win32_TerminalServiceSetting&quot;)  \r\n  For Each objItem in colItems  \r\n    Select Case objItem.LicensingType  \r\n      Case &quot;1&quot; ' Remote Administration\r\n        isTerminalServer = False\r\n      Case &quot;2&quot; ' Per Device\r\n        isTerminalServer = True\r\n      Case &quot;4&quot; ' Per User\r\n        isTerminalServer = True\r\n      Case &quot;5&quot; ' Not configured yet\r\n        isTerminalServer = True\r\n      Case Else\r\n        isTerminalServer = False  \r\n    End Select\r\n  Next  \r\n  Set objWMIService = Nothing  \r\n  Set colItems = Nothing  \r\nEnd Function  \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Updated 19th October 2010&#8230; This is what I call the &#8220;bees knees&#8221; of scripts for deploying VMware Tools. It will detect if it&#8217;s being installed on a Terminal\/Citrix Server, and remove the appropriate components that may impede performance, etc.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[5,40,38],"tags":[416,107,92,108,417],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-scripting","category-vmware","category-xenapp","tag-citrix","tag-install-vmware-tools","tag-presentation-server","tag-vmtools","tag-xenapp"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":49,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":675,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/220\/revisions\/675"}],"wp:attachment":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}