0

i have an code and i want to do a goto but i dont know how to make it in Powershell

:yea
taskkill /im wordpad.exe /f
(get-process | ? {$_.Description -eq "Notepad"}).kill()
goto yea

i tried to read how to make it in google but i dont understeand anything xd maybe its simple but i dont know how to make it

i read it something of

break and continue

please help me (:Yea and goto yea its when i want the loop)

aa a

a a

a a

a a a

a a a a

  • In the situtation you mentioned, you should use a while loop instead. Why do you want goto specifically? – OwlsSleeping Apr 13 '21 at 16:21
  • and while loop for kill? – Esperento57 Apr 13 '21 at 18:34
  • You can use continue or break with a label, but it's usually for nested loops https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_continue?view=powershell-7.1#using-a-labeled-continue-in-a-loop – js2010 Apr 13 '21 at 19:55

1 Answers1

1

Use a while() loop:

while($true){
  taskkill /im wordpad.exe /f
  (get-process | ? {$_.Description -eq "Notepad"}).kill()
}
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206