pythonpython-2.7google-chromepython-webbrowser

how to open chrome in incognito mode from Python


This works, in powershell:

Start-Process chrome.exe -ArgumentList @( '-incognito', 'www.foo.com' )

How can this be achieved from Python?


Solution

  • Use the os module to execute the command.

    import os
    os.system("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -ArgumentList @( '-incognito', 'www.foo.com'" )
    

    More information on os.system can be found here.