これはpowershellで機能します:
Start-Process chrome.exe -ArgumentList @( '-incognito', 'www.foo.com' )
これはPythonからどのように達成できますか?
これはpowershellで機能します:
Start-Process chrome.exe -ArgumentList @( '-incognito', 'www.foo.com' )
これはPythonからどのように達成できますか?
私のコンピューターでは intboolstring のアプローチは機能しません。代替のより機能的なアプローチは、subprocess モジュールから call() を使用することですが、コマンドが変更された場合は system() で引き続き可能です。
from subprocess import call
call("\"C:\Path\To\chrome.exe\" -incognito www.foo.com", shell=True)
または system() を使用:
from os import system
system("\"C:\Path\To\chrome.exe\" -incognito www.foo.com")
クロムがパスに追加されている場合、または次のようにpowershellを介してコマンドを実行する場合、「chrome.exe -incognito www.foo.com」のみを使用してクロムを開始することもできます。
system("powershell -C Start-Process chrome.exe -ArgumentList @( '-incognito', 'www.foo.com' )")
ただし、この方法は chrome.exe をパスに追加するよりもはるかに遅くなります。
import subprocess
subprocess.Popen(["C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "-incognito", "www.google.com"])