https://cafe.daum.net/candan/GGFN/287 배치파일의 경우
https://lazyadmin.nl/powershell/start-process/
Start-Process -FilePath "c:\temp\example.bat" -Wait
Start-Process -FilePath "powershell" -Wait
이렇게 하면 파워쉘을 두개 뛰울수 있다 하지만 뛰우는 뛰움과 동시에 먼져 것은 쓸수 없다.
두번을 입력 해도 하나만 열린다
https://www.thomasmaurer.ch/2021/03/how-to-chain-multiple-powershell-commands-on-one-line/
현재 프로세스 보기
Get-Process
https://stackoverflow.com/questions/36372049/how-to-run-multiple-powershell-scripts-at-the-same-time
workflow RunScripts {
parallel {
InlineScript { C:\myscript.ps1 }
InlineScript { C:\myotherscript.ps1 }
}
}
두가지 이게 잘 된다 한대.. 멈쳐서 있음.
Start-Process Powershell.exe -Argumentlist "-file C:\myscript.ps1"
Start-Process Powershell.exe -Argumentlist "-file C:\myscript2.ps1"
샘플 파일
1.ps1
Start-Process Powershell.exe -Argumentlist "-file test1.ps1"
Start-Process Powershell.exe -Argumentlist "-file test2.ps1"
test1.ps1
$ports=get-content out_1.csv
Foreach($port in $ports){
New-NetFirewallRule -DisplayName 'A HTTP-Inbound' -Profile any -Direction Inbound -Action Block -RemoteAddress $port | Out-Null
}
exit
실할때
.\1.ps1
잘 안되는 줄 알았는대 잘 실행 된다 마지막 줄에 ext 넣어 주면 종료 하고 창을 닫는다.
한대 문제는.. 이게 멀티가 안된다. New-NetFirewallRule 이놈이 문제 인대.. 응답을 두개로 주어도 하나만 받음.
-_-;; 즉 여러개의 프로세스 작업을 하면 이 방법이 먹힐지 모르지만..
https://stackoverflow.com/questions/72498758/powershell-loop-script-the-process-is-taking-too-long-cant-we-speed-up-the-pr?noredirect=1#comment128072699_72498758
외국애가 오히려 멀티로 해서 속도가 더 느려진거라고함.. 단일로 해야 오히려 빠르다고. 결론적으로..
응답을 받는 프로세스가.. 응답을 하나만 받는 애들면 느릴수 밖에 없는 거임 즉 옛날로 따지면 싱글 코로냐? 멀티 코어냐? 이 차이.. 옛날 컴퓨터니깐 싱클 코어인거임 이놈의 윈도우의 방어벽도. 옛날 그대로라 싱글 코어만 씀..
반면 요즘의 경우 크롬이나 파이어 폭스의 경우 프로세스를 다중으로 실행 시켜서 메모리를 분산 시키고 멀티로 돌려서 프로세스의 속도를 증가 시키고 쾌적 하게 설개 했음. 대충 그런 이야기 ㅎㅎ.. 결론은 이건 뻘짓이였음 ㅠㅠㅠㅠㅠ. 쩝.
그래도 덕분에 멀티로 실행 하는거 공부가 됨 ㅎㅎb 따봉.
그리고 파워쉘이. cmd 보단 쾌적 했음. 이상한 ms 애들 cmd를 개발해주어야 하는대 단어가 존니 긴 파워쉘만 죽어라 개발함..
단어가 개김 ㅠㅠ.. 단어로 소설 써도 될듯. ㅠ
와.. 외국애가 해결 해줌 ㅋㅋㅋ..
https://docs.microsoft.com/ko-kr/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3
파워쉘 7을 깔라서 해서 깔아서 안되고 느렸는대.. 바뀐 명령어로 하니깐 겁나 빨라짐 ㅎㅎb 대박.
이건 빠른 버전 파워쉘7을 켜야 함 그리고 명령어도 다름. 여기서 실행 하는 걸 보려면 | Out-Null 삭제 해야 한다. 그래서 테스트를 보기 위해서 test 파일 둘중 하나는 Out-Null 이게 제거 되어 있다.. 실행 화면 보라고 ㅎㅎ. 결론. 잘됨.
1.ps1
Start-Process Pwsh.exe -Argumentlist "-file test1.ps1"
Start-Process Pwsh.exe -Argumentlist "-file test2.ps1"
test1.ps1
get-content "out_1.csv" | Foreach-Object -parallel {
New-NetFirewallRule -DisplayName 'A HTTP-Inbound' -Profile any -Direction Inbound -Action Block -RemoteAddress $_ | Out-Null
}
https://stackoverflow.com/questions/35903038/run-multiple-powershell-scripts-sequentially-on-a-folder-combine-scripts-int
한번에 여러개를 실행 하니 잘 안될때.. 두개씩 묶어서 실행 하고 싶을때. 즉 2개를 실행 하고 멈추고 다음을 실행 하시요 할때 끝에 -wait 를 주면 된다
Start-Process Pwsh.exe -Argumentlist "-file test1.ps1"
Start-Process Pwsh.exe -Argumentlist "-file test2.ps1" -wait
Start-Process Pwsh.exe -Argumentlist "-file test3.ps1"
Start-Process Pwsh.exe -Argumentlist "-file test3.ps1" -wait
이렇게 하면.. 두개를 동시에 진행 하고. 3번째는 기다린다. 그리고 4번째 또 기다리고.. 한줄씩 -wait를 걸면 하나씩 실행 하게 된다.
첫댓글 https://ohgyun.com/173 여러개 동시에 실행
스레드 명령어라고 하네요.
https://www.poftut.com/powershell-start-process-command-tutorial-examples/
https://lazyadmin.nl/powershell/powershell-loops-for-foreach-do-while-until/
반복 하는대 창 닫기가 어렵다 ㅠ
https://docs.microsoft.com/ko-kr/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3 외국애가 파워쉘 7을 설치 해보라고함 ㅎㅎ 올 이런것도 있네