Runs Start-Process Activity Asynchronous?

Hello Community,
a tiny question: Executes the Start-Process activity the file name as an asynchronous process?
I assume that’s the case, but I’m not sure and I could not find a clear answer.
Thanks and best regards
Stefan

Hi @StefanSchnell,
Could you extend your thought? Small example or something like that :slight_smile:

@Pablito

Hello Pawel,
Start-Process executes a new process with the given file name. In my example I start node.exe, with the parameters test.js, 1 and 1. When node.exe is started, runs it independently from the following UiPath activities? I mean runs it seperately, asynchronous parallel from the following UiPath activities? Or waits Start-Process until node.exe was finished and only then will the following activities be performed?
Thanks and best regards
Stefan

StartProcess

Based on my experience every application/compilator which had something to do with codding was working from the top to the bottom one-by-one each command. I guess similar is here but it’s easy to find it out. I made an example:

  1. Prepared two ideantical scripts in .txt file (It will count from 1 to 10 and will create text file named “test.txt”. Second is identical but will create “test2.txt”.
for ($a=1; $a -lt 11;$a++)
{
    Write-Output "Iteration number: " $a | Out-File C:\Users\Pablito\Desktop\test.txt -Append
    Start-Sleep 1
}
  1. Then simple workflow:
    image
  2. And finally we can observe if both txt files will show up in the same moment or there will be 10 seconds of pause between.

Hint: 10 seconds is the answer :slight_smile: So I guess in your case next activities will start their job after node.exe will do what has been set in argument :slight_smile:

1 Like

@Pablito

Hello Pawel,
thank you very much for your reply and your effort.

I tried Start-Process in chain three times and get three command line windows parallel:

I assume Start-Process works asynchronously, otherwise cmd would start one after the other.

Best regards
Stefan

I’m not that sure. I think CMD is just simple console and it’s starting so fast that you see like it’s starting all at the same time. We couldn’t call it “Sequence” in UiPath then :slight_smile: Another thing is that there are some activities called “Parallel” -> image. And last but not least there is a Delay activity and you can just use it here like this:

EDIT:
I read carefully once again your whole topic and here is the conclusion based on this:

So you have seen my example with powershell right? Studio waited with starting second powershell untill the first one ended the script. But the fact is that script was provided in Studio. But if my workflow would have only activity to start process and the script would be triggered from the outside of Studio then workflow would not wait and would start next powershell activity.

2 Likes

@Pablito

Hello Pawel,
thank you very much for your reply and your effort.

I tried your example and it works as perfect as you described. However, my question refers to Start-Process actvity. So I have implemented your example with it.

StartProcess003

Test1.ps1 looks like this:

for ($a=1; $a -lt 11;$a++) {
    Write-Output "Iteration number from Test1.ps1: " $a | Out-File C:\Dummy\test.txt -Append
    Start-Sleep 1
}

Test2.ps1 looks like this:

for ($a=1; $a -lt 11;$a++) {
    Write-Output "Iteration number from Test2.ps1: " $a | Out-File C:\Dummy\test.txt -Append
    Start-Sleep 1
}

You see, the only difference is the text in Write-Output cmdlet, to distinguish who wrote what.
And here is my result:

Iteration number from Test1.ps1: 
1
Iteration number from Test2.ps1: 
1
Iteration number from Test1.ps1: 
2
Iteration number from Test2.ps1: 
2
Iteration number from Test1.ps1: 
3
Iteration number from Test1.ps1: 
4
Iteration number from Test2.ps1: 
4
Iteration number from Test1.ps1: 
5
Iteration number from Test2.ps1: 
5
Iteration number from Test1.ps1: 
6
Iteration number from Test2.ps1: 
6
Iteration number from Test1.ps1: 
7
Iteration number from Test2.ps1: 
7
Iteration number from Test1.ps1: 
8
Iteration number from Test2.ps1: 
8
Iteration number from Test1.ps1: 
9
Iteration number from Test2.ps1: 
9
Iteration number from Test1.ps1: 
10
Iteration number from Test2.ps1: 
10

So, the discussion with you answers my question :slightly_smiling_face:
Start-Process starts asynchronously and independently from the UiPath sequence - very good to know that now definitely.

Thanks again and best regards
Stefan

2 Likes

Thank you! I learned something as well from our discussion :slight_smile:

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.