There are two ways to run PowerShell script
from QTP as shown below,
- · Exec command
- · Run Command
The above two methods use WshShell Object to launch other
programs.
Run
Method:
Run method runs a program in a new process.
'Creates WshShell
object and returns it to objShell
Set objShell=CreateObject("Wscript.shell")
'Runs the PowerShell script
objShell. Run ("powershell -noexit -file c:\fso\email.ps1")
Set objShell=CreateObject("Wscript.shell")
'Runs the PowerShell script
objShell. Run ("powershell -noexit -file c:\fso\email.ps1")
The Run method returns an integer.
The Run method starts a program running in a new Windows process. You
can have your script wait for the program to finish execution before
continuing. This allows you to run scripts and programs synchronously.
Exec
Method:
Exec method runs the application or program
in child command line.
Syntax:
Object. Exec (strCommand)
Object is WshShell object.
strCommand-string value indicating the
command line used to run the application.
No comments:
Post a Comment