Add Single Threaded Apartment (STA) Switch to Properties of Invoke PowerShell Activity

Hello UiPath,

today I tried Windows Inter Process Communication (IPC) via Windows clipboard. To set some text in the clipboard I want to use a PowerShell script.

Set-Clipboard "Hello World from PowerShell"

The PowerShell script itself works inside ISE as expected. So I create an easy sequence inside UiPath.

SetClipboard001

It is very easy to understand. I read the PowerShell script as text, invoke it and after that I want to get the text from the clipboard, which was set by the PowerShell script, and print it.

But I got this error message:

SetClipboard002

In my opinion could it be profitable to add an additional Single Threaded Apartment (STA) switch to your Invoke PowerShell activity, and that is my suggestion. I assume (and hope) it is very easy to realize, because the dotNET Framework offers in the namespace System.Management.Automation.Runspaces in the class Runspace the property ApartmentState to do that. I could looks like this.

SetClipboard003

On this way we have the possibility to use PowerShell scripts which includes controls, features or static methods as explained in this blog of SAPIEN.

Thanks for all your efforts and best regards
Stefan

Thanks for sharing some beautiful information guys and I agree with you.

1 Like

Hi,
Thank you for your suggestion. I added it to our internal ideas tracker for our team to consider.

1 Like

Did you find any workaround for this issue? Can we somehow set threading to STA manually or by some invoke code?

Hi @Marta,
This case is still in the queue and under review.