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

Running a Do loop while running other code

$
0
0

My explanation may be lengthy, so sorry in advance.

This is what I am trying to accomplish:  I want to install a program while ensuring a service is turned off, and remains off for the duration of the installation.  The service I'm stopping will try to restart itself every minute or so, so I've created a Do loop to check if the service is running and stop it if it is.  I suppose I could disable the service, but if possible, I'd rather not go that route - I just want to stop it, and then restart it after the installation.

My question is this:  How do I start the Do loop, have it run for the duration, while also running the installation portion of the script?  Then, at the end of the installation, I will stop the loop and turn on the service.

I suppose I could create a second .ps1 file and call it from the installation .ps1, but I would like to have all the code contained in one file.

Is this possible?  Suggestions are welcome.

Thank you,

Ed


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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