Forum Discussion
- Colin_McCraeCommunity Hero
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
- v1kSandi3goOccasional 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.
- HKosovaSmartBear 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);
Related Content
- 5 years ago
- 4 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 6 days ago