start-process then wait until ping returns true

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Martin Thomsen Martin Thomsen 3 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #53839
    Profile photo of Martin Thomsen
    Martin Thomsen
    Participant

    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
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

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

    Get-Help Start-Process -Online

    #53845
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    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
    Profile photo of Martin Thomsen
    Martin Thomsen
    Participant

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

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.