How to: stdout from command line to UiPath variable

Hello, if you need to grab the ‘stdout’ output from a command line process (“C:> dir C:\work*.*”, for example), or from a PowerShell script, this may help.

The attached workflow uses AutoHotKey.Interop and Invoke Code. Included are Ui_Var3.ahk, StdOutToVar.ahk (the function lib), uipath_test.csv, and AA11.xaml.

(I will test this with the bash commands available on Win10 when I have a chance to use a system that has Win10 and bash installed. I believe making the output of Linux shell commands available to UiPath would be useful. I will also experiment with alternate implementations of StdOutToVar, which can be found here. My hat’s off to these coders.)

Feedback appreciated.

Input dialog for the command:

Command In

Output to UiPath message box from “Invoke Code”:

A PowerShell command (‘awk-ish’) in, to pull a column from a csv file:

PS Command in

And the output of the extracted column to a Message Box:

PS 'awk' clone out

All feed back appreciated, once again!
regards,
burque505

StdOutToVar-UiPath.zip (4.3 KB)

2 Likes

how to integrate AutoHotKey.Interop and Invoke Code from uipath. when i download StdOutToVar-uipath.zip and try to open in uipath. i am getting this below error “Could not find type ‘AutoHotkey.Interop.AutoHotkeyEngine’ in assembly ‘AutoHotkey.Interop’. Row: 61, Column: 8” c

Hi, I’m now getting the same error. This is probably due to an update in the script activities, I’ll investigate and get back to you. This is worrisome.
Regards,
burque505

Problem solved (for me anyway :). I need to update Uipath.Script.Activities to version 1.0.6710.16240. For me, it resides at C:\Users\not_really_me.nuget\packages\uipath.script.activities\1.0.6710.16240\uipath.script.activities.1.0.6710.16240.nupkg. I updated it via the “Manage Packages” icon from the ribbon. I noticed also that the 32 bit version of powershell.exe is not in my path. If you are running 64-bit windows (I imagine you are) and the example powershell command does not work, please try this instead:

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe Get-Content .\uipath_test.csv | %{ $_.Split(',')[1]; }

I just tried it that way, and all worked. A gif of the Activities install on my system is below.

Please let me know if doesn’t work, and I appreciate you catching that error.
Regards,
burque505

it works thanks:)

I’m glad to hear that.
Regards,
burque505