Forum Discussion

v1kSandi3go's avatar
v1kSandi3go
Occasional Contributor
8 years ago

How to automate the process of Restoring the snap shot on VM using TestComplete or Win Batch File?

Hi All,

 

Is it possible to Automate the process of restoring the snap shot on VM and/or Automate the process of restoring the snap shot on VM using TestComplete or windows batch file? currently the set up or our VM is under Linux with VMware vSphere client. We able to access the VM via SSH(using batch file) and Putty. Now, my question is there anyway or alternative way to access the VM using Microsoft "Telnet" technologies (Telnet Client/Server Configurations)? Is there any insights to share?

 

 

Thanks in advance.....

4 Replies

  • Never done it myself ...

     

    But I suspect you'll want to be making use of the tools VMware supply for doing this.

     

    So either: https://code.vmware.com/web/dp/sdk/55/vsphere-cli

     

    Or: https://communities.vmware.com/community/vmtn/automationtools/powercli

     

    They also provide a Perl SDK, but I suspect that won't be what you're after.

     

    PowerShell is likely to be the easiest option for a simple restore from snapshot. TestComplete is fine with running PowerShell scripts. See here: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/running-powershell-scripts.html

    • v1kSandi3go's avatar
      v1kSandi3go
      Occasional Contributor

      Hi,

       

      Thanks for your insights, however after I tried this, TestComplete run it without error. But it seems not triggering the action based on my script?? Here's my script:

       

      function Batch()

      { 

      // Run a script

      Sys.OleObject("WScript.Shell").Run("powershell -file C:\windows\system32\startps.ps1"); 

       

      }

       

      Do I need to consider the security or policy on my desktop? I ran manually the *.ps1 file manually and the script works accordingly, but after ran the script above using TestComplete the action is not been performed.

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        In JScript/JavaScript you need to double the backslashes in paths:

        Sys.OleObject("WScript.Shell").Run("powershell -file C:\\windows\\system32\\startps.ps1");

        Better yet, do not hardcode the "C:\Windows" path and use an environment variable instead:

        Sys.OleObject("WScript.Shell").Run("powershell -file %windir%\\system32\\startps.ps1");

        Also note that, by default, the WshShell.Run() method returns immediately and does not wait for the command to complete. If you need to wait for the command completion, set the third parameter of the Run() method to true:

        Sys.OleObject("WScript.Shell").Run("powershell -file %windir%\\system32\\startps.ps1", 0, true);