mercredi 29 juin 2016

Powershell Background if Ping script

I have an old CMD Script which I want to convert into a Powershell Script which runs in the Background, the CMD Script:

@echo off
timeout /t 300 /nobreak
ping -n 1 -i 135 -w 130 192.168.1.250
if errorlevel 1 goto Ende
goto Program
:Program
start "" "C:\Program Files (x86)\XXX\XXX.exe"
Exit

:Ende
Exit

The Script checks if the Router is pingable, if yes it starts a program. I have completly zero experience with either CMD or Powershell(see Goto <.<), I tried to do it with google and found some solutions to run it in background but they didn't really work out for me.

The Sleep option should work with start-sleep -s 300, the Ping Check with if (test-connection -computername Server01 -quiet) but im not completly sure how to do an if-statement around the ping.

Greetings

Aucun commentaire:

Enregistrer un commentaire