0

I've been trying to launch Anaconda Powershell Prompt using pywinauto package on jupyter lab. I copied the code from swapy(tried both 64 bit and 32 bit version). It returns a syntax error. Where's the problem?

from pywinauto.application import Application
app2 = Application().Start(cmd_line=u'"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -ExecutionPolicy ByPass -NoExit -Command "& 'C:\\Users\\USER\\anaconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate 'C:\\Users\\USER\\anaconda3' "')
consolewindowclass = app2.ConsoleWindowClass
consolewindowclass.Wait('ready')

app2.Kill_()

enter image description here

Tried running the code multiple time changing the types of quote unquote single or double. pywinauto is installed using !pip install pywinauto

  • Please post the a error as text not screenshot. – toyota Supra May 22 '23 at 08:09
  • Why do you want to automate PowerShell commands by GUI automation tool? What is your high level task? Maybe there is better way at all. – Vasily Ryabov May 22 '23 at 16:42
  • Careful with your quotes: your command contains single quotes, which close the opening quote of your `cmd_line` definition too soon. You need to escape embedded single quotes with a backslash. – joanis May 23 '23 at 03:22

0 Answers0