Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Infinite While loop

$
0
0

Hello all,

I've got a script that has a While statement an example of it is:

 While (1 -eq 1) {

      If (Test-Path -path 'C:\My\Path)

      { break }

      start-sleep -Seconds 5
        }

This works well and does its job...my question is (I'm sure you can guess) how can I use a loop in a more intelligent way so that I dont run the risk of it running forever if the condition isn't met?

Many thanks for any guidance.

Carl


Carl Barrett | Twitter: @Mosquat


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>