Executing powershell file from Test Complete script
Hi Everyone,
I have a PickupTest.ps1 which triggers the software to launch. C:\_Test\abc\AutomatedScripts\My Tests\PickupTest.ps1
The below line of code sometimes works but most times the Powershell seems to open but the software does not launch. The problem seems to be the space in My Test in the path which I unfortunately cannot change at the moment.
WshShell.Run("powershell -file \"" + pathvar + "\\My Tests\\PickupTest.ps1")
The other alternative someone suggested was to create a temporary drive and pick up the file from there to avoid space issue, but it also does not seem to be working all the time.
WshShell.Run("powershell -file B:\PickupTest.ps1");
Can anyone help me deal with the space in the path when running powershell please?
Thanks in advance.
Hi,
Assume that pathvar contains the 'C:\Project' value:
your line of code
"powershell -file \"" + pathvar + "\\My Tests\\PickupTest.ps1"
will evaluate to
'powershell -file "C:\Project\My Tests\PickupTest.ps1'
which seems to be just incorrect (lack of closing double-quote -- check this in debugger)
Does it help if you change this line of code to this:
WshShell.Run("powershell -file \"" + pathvar + "\\My Tests\\PickupTest.ps1\"")
(note added \" at the end of code line)