Here’s a step-by-step example of how to append command line arguments to the Chrome shortcut’s "Target" field:
-
Find and Right-Click the Chrome Shortcut: Locate the Google Chrome shortcut you use. This could be on your desktop, in your start menu, or pinned to your taskbar. If it’s in your taskbar, you might need to right-click on the icon, then right-click on "Google Chrome" in the list that pops up, and then click on "Properties."
-
Access Properties: Right-click on the shortcut and select "Properties" from the context menu.
-
Modify the Target Field:
- In the "Shortcut" tab of the Properties window, you will see a "Target" field. This contains the path to the Chrome application, usually enclosed in quotes. For example:
"C:\Program Files\Google\Chrome\Application\chrome.exe"
- To append command line arguments, you’ll place a space after the closing quote of the path, and then type your desired command line arguments.
- In the "Shortcut" tab of the Properties window, you will see a "Target" field. This contains the path to the Chrome application, usually enclosed in quotes. For example:
-
Example of Adding a User Data Directory Argument:
- Let’s say you want Chrome to store its user data (including cookies and cache) in a specific directory, like
D:\ChromeUserData\Profile1
. - You would append
--user-data-dir="D:\ChromeUserData\Profile1"
to the Target field. - The Target field after appending would look like this:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --user-data-dir="D:\ChromeUserData\Profile1"
- Let’s say you want Chrome to store its user data (including cookies and cache) in a specific directory, like
Here’s a visual breakdown:
Before appending:
"C:\Program Files\Google\Chrome\Application\chrome.exe"
After appending:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --user-data-dir="D:\ChromeUserData\Profile1"
- Apply the Changes: Click "Apply" to save your changes, then "OK" to close the Properties window.
Now, when you open Chrome using this shortcut, it will launch with a separate user data directory as specified. This allows you to maintain different browsing sessions, each with their own cookies, cache, and settings, without affecting the default Chrome user profile. This method is particularly useful for testing, privacy, and managing multiple accounts.
刷课的时候通过改写以下代码一次性创建多个窗口登录账户:
import subprocess
# Specify the path to the Chrome executable
chrome_path = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
# Specify the custom user data directory (for cookies, cache, etc.)
user_data_dir = r'C:\Users\xxx\Desktop\user2'
# Additional Chrome command line arguments can be added here
chrome_args = f'--user-data-dir="{user_data_dir}"'
# Launch Chrome with specified command line arguments
subprocess.Popen(f'"{chrome_path}" {chrome_args}')
这个操作有点比较吃内存。
也可以通过浏览器扩展实现(未测试):
Multi-Account Containers
(Firefox)SessionBox
(Chrome)
Answer from GPT-4