1 Reply Latest reply on Apr 3, 2009 2:59 PM by paul_xtravirt

    VMware Tools Status update/ Windows scripting help

    timcwhite Enthusiast





      I'm trying to recreate an alawrm that I hade setup previous within virtual center that would monitor a Virtual machines heartbeat. I had a script that would restart the VMtools service on a windows box when the alarm went off. Below is the script:



      +Set objSWbemLocator = CreateObject("WBemScripting.SWbemLocator") +

      +set objWMIService = objSWbemLocator.ConnectServer (Wscript.Arguments(0), "root\cimv2", "domain\useraccount", Wscript.Arguments(1)) +

      +*Set colServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name = 'vmtools'")* +

      +For Each objService in colServices +

      +errReturnCode = objService.StopService() +


      +Wscript.Sleep 20000 +

      +For Each objService in colServices +

      +errReturnCode = objService.StartService() +




      The command that I would run is: cscript.exe c:\scripts\restarttools.vbs password






      When i run the script on a local machine I receive the following error:



      SWbemlocator: User credentials cannot be used for local connections






      Can anyone help me with this? I need to get this working as some of my backups are failing because Virtual Center shows the Tools Status as being Down









      Thanks in advance



        • 1. Re: VMware Tools Status update/ Windows scripting help
          paul_xtravirt Expert


          I am assuming that what you are doing when you get the error, is running that script 'locally' on the machine that is hosting it for testing? If so, it will not work because of this line:



          set objWMIService = objSWbemLocator.ConnectServer (Wscript.Arguments(0), "root\cimv2", "domain\useraccount", Wscript.Arguments(1))



          You cannot pass a domain\useraccount and password if you are running it on the local machine. You would need to amend the line so it is like the one below:



          Set objWMIService = objSWbemLocator.ConnectServer(Wscript.Arguments(0), "root\CIMV2")




          If you found this helpful, please consider awarding points