WshShell Object

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The WshShell object provides access to the native Windows Shell. It is similar to the Sys.OleObject["WScript.Shell"] object and fully inherits its features.

For a detailed reference on WshShell methods and properties, see the WshShell Object article in the MSDN Library.

Example

Below is a sample script that demonstrates how you can use the WshShell object to run PowerShell scripts and commands from TestComplete tests.

JavaScript, JScript

// Run a script
WshShell.Run("powershell -file C:\\MyScript.ps1");

// Run one command
WshShell.Run("powershell -command echo Test");

Python

# Run a script
WshShell.Run("powershell -file C:\\MyScript.ps1")

# Run one command
WshShell.Run("powershell -command echo Test")

VBScript

' Run a script
Call WshShell.Run("powershell -file C:\MyScript.ps1")

' Run one command
Call WshShell.Run("powershell -command echo Test")

DelphiScript

// Run a script
WshShell.Run('powershell -file C:\MyScript.ps1');

// Run one command
WshShell.Run('powershell -command echo Test');

C++Script, C#Script

// Run a script
WshShell["Run"]("powershell -file C:\\MyScript.ps1");

// Run one command
WshShell["Run"]("powershell -command echo Test");

See Also

Running PowerShell Scripts From TestComplete
Script Extensions
Creating Runtime Objects Tutorial

Highlight search results