# start-process then wait until ping returns true

**URL:** <https://forums.powershell.org/t/start-process-then-wait-until-ping-returns-true/7158>\
**Category:** PowerShell Help\
**Created:** [September 8, 2016, 3:34am UTC](https://forums.powershell.org/t/start-process-then-wait-until-ping-returns-true/7158 "2016-09-08T03:34:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin-thomsen](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@martin-thomsen](https://forums.powershell.org/u/martin-thomsen)\
**Post date:** [September 8, 2016, 3:34am UTC](https://forums.powershell.org/t/start-process-then-wait-until-ping-returns-true/7158/1 "2016-09-08T03:34:49Z")

</div>

Hi

I need something that will start a process then wait until ping is true

$ ‘C:\tmp\myVPN.exe’

do {$ping=test-connection -computer “myserver.domain.local” -quiet} until($ping)

#then do more stuff after above ping returns true.

but it halts after starting the software since the vpn doesn’t shut down (obviously)

how can I start the vpn in a seperate process? or whatever I need to do ?

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [September 8, 2016, 3:39am UTC](https://forums.powershell.org/t/start-process-then-wait-until-ping-returns-true/7158/2 "2016-09-08T03:39:45Z")

</div>

The Start-Process cmdlet will launch an executable in a separate process unless being told otherwise.

Get-Help Start-Process -Online

---

<div class="post-metadata">

**Author:** ![rdtechie](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rdtechie/32/273_2.png) [@rdtechie](https://forums.powershell.org/u/rdtechie)\
**Post date:** [September 8, 2016, 3:44am UTC](https://forums.powershell.org/t/start-process-then-wait-until-ping-returns-true/7158/3 "2016-09-08T03:44:00Z")

</div>

Daniel is right. Use Start-Process here like this:

```
$process = Start-Process -FilePath 'C:\tmp\myVPN.exe' -PassThru
```

I’m putting the returned object in a variable, so that you can use it to do some checks on. Like this:

```
$process | Get-Process
```

---

<div class="post-metadata">

**Author:** ![martin-thomsen](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@martin-thomsen](https://forums.powershell.org/u/martin-thomsen)\
**Post date:** [September 8, 2016, 9:22am UTC](https://forums.powershell.org/t/start-process-then-wait-until-ping-returns-true/7158/4 "2016-09-08T09:22:46Z")

</div>

Thx guys… I actually did something else… I added ‘-asJob’ which seems to achieve the same thing… but I will definetely change to the above…

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:40pm UTC](https://forums.powershell.org/t/start-process-then-wait-until-ping-returns-true/7158/5 "2024-05-16T20:40:35Z")

</div>

Closed on May 16, 2024, 8:40pm UTC


