--disable-gpu 인수를 허용하는 위치 매개변수를 찾을 수 없습니다.

--disable-gpu 인수를 허용하는 위치 매개변수를 찾을 수 없습니다.

자동화를 통해 로컬 웹페이지를 인쇄할 수 있는 powershell 프로세스를 만들려고 합니다.

start-process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --headless --disable-gpu --print-to-pdf="C:\Temp\createPdf180304023549.pdf" http://localhost/

그런데 문제는 계속해서 그런 말이 나온다는 것이다.

--disable-gpu 인수를 허용하는 위치 매개변수를 찾을 수 없습니다.

그러나 내가 사용하는 명령은https://developers.google.com/web/updates/2017/04/headless-chrome

내가 뭘 잘못했나요?

답변1

ArgumentList다음과 같이 명령에 매개변수를 추가합니다 .

start-process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -ArgumentList @"--headless --disable-gpu --print-to-pdf="C:\Temp\createPdf180304023549.pdf" http://localhost/"

print-to-pdf 인수에서 큰따옴표를 이스케이프 처리하기 위해 인수는 큰따옴표로 묶이고 앞에 at 기호(@)가 추가되었습니다.

이 매개 변수가 없으면 PowerShell은 Chrome용 인수를 Start-Process cmdlet의 인수로 해석합니다.


시작 프로세스

답변2

그것은 나를 위해 일하고

start-process chrome.exe -ArgumentList "--headless --print-to-pdf=C:\Users\{User}\Desktop\AllPdf\pdf4.pdf https://www.google.com"

관련 정보