Forum Discussion
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
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.
- HKosova8 years agoSmartBear 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);
- v1kSandi3go8 years agoOccasional Contributor
thanks for your good solution, however after I tried those changes still doesn't really works in my end. I ran my script manually via powershell application It works fine but running the scripts using TestComplete is not really works, its not giving the right output. If you want I can send to you my recorded video privately.
Related Content
- 5 years ago
- 4 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 7 days ago