-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchrome-run.py
30 lines (26 loc) · 1.13 KB
/
chrome-run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import subprocess
import os
import sys
def open_chrome_with_user_data():
# Check the operating system
if os.name == 'nt': # Windows
# Paths for Chrome in regular and x86 (32-bit) directories
chrome_path = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
chrome_path_x86 = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
# Check if Chrome is in the regular directory
if os.path.isfile(chrome_path):
subprocess.run([chrome_path, "--remote-debugging-port=9222"])
# Check if Chrome is in the x86 directory
elif os.path.isfile(chrome_path_x86):
subprocess.run([chrome_path_x86,"--remote-debugging-port=9222"])
else:
print("Chrome executable not found in standard locations.")
sys.exit(1)
elif sys.platform == "darwin": #Macos
subprocess.run(["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "--remote-debugging-port=9222"])
else:
subprocess.run(['google-chrome', "--remote-debugging-port=9222"])
# Close the script
sys.exit()
if __name__ == "__main__":
open_chrome_with_user_data()