We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
For example,
function Test()
{
var oExec = WshShell.Exec("powershell.exe -Command \"C:\\Temp\\Book2.ps1\" -excelfile \"C:\\Temp\\Book2.xlsx\"");
while (oExec.Status == 0) {
aqUtils.Delay(1000);
}
while (!oExec.StdOut.AtEndOfStream) {
Log.Message(oExec.StdOut.ReadLine());
}
}
Thanks a lot this solves all my problems
Thank you once again for all the effort
After a few attempts I am able to run the power shell script but I am unable to read the out put from it using the test completely. I have already gone through the documentation but nothing is working for me
sample code return an empty message
function GetProcesses()
{
var oExec = WshShell.Exec("powershell -File D:\ABS\Untitled1.ps1");
oExec.StdIn.Close(); // Close standard input before reading output
// Get PowerShell output
var strOutput = oExec.StdOut.ReadAll();
// Trim leading and trailing empty lines
strOutput = aqString.Trim(strOutput, aqString.stAll);
// Post PowerShell output to the test log line by line
aqString.ListSeparator = "\r\n";
for (var i = 0; i < aqString.GetListLength(strOutput); i++)
{
Log.Message(aqString.GetListItem(strOutput,i));
}
}
PowerShell code
$Path = 'D:\ABS\ABS.xlsx'
$Excel = New-Object -Com Excel.Application
$Workbook = $Excel.Workbooks.Open($Path)
$page = 'PLANT'
$ws = $Workbook.worksheets | where-object {$_.Name -eq $page}
$cells = $ws.Columns.Item(9).hidden
return $cells
$workbook.Close($true)
$excel.quit()