start-process then wait until ping returns true

Welcome Forums General PowerShell Q&A start-process then wait until ping returns true

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
2 years, 2 months ago.

  • Author
    Posts
  • #53839

    Participant
    Points: 0
    Rank: Member

    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 ?

  • #53843

    Moderator
    Points: 24
    Team Member
    Rank: Member

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

    Get-Help Start-Process -Online

  • #53845

    Participant
    Points: 26
    Rank: Member

    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
  • #53904

    Participant
    Points: 0
    Rank: Member

    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..

The topic ‘start-process then wait until ping returns true’ is closed to new replies.