import os from win32com import client def create_chrome(name,num): chrome_path="C:\Program Files\Google\Chrome\Application\chrome.exe" user_dir_data=f"D:\data\google\Chrome{num}" #定义快捷方式的目标路径和名称,快捷方式的路径 # short_cut_path=os.path.join(os.path.expanduser("~"),"Desktop","北京.lnk") short_cut_path=os.path.join("D:\data\google",f"{name}{num}.lnk") # 创建windows快捷方式对象 shell=client.Dispatch("WScript.Shell") short_cut = shell.CreateShortcut(short_cut_path) short_cut.TargetPath=chrome_path short_cut.WindowStyle=1 short_cut.IconLocation=chrome_path short_cut.Description="Google Chrome" short_cut.WorkingDirectory=os.path.dirname(chrome_path) short_cut.Arguments=f"--start-maximized --user-data-dir={user_dir_data}" #保存快捷方式 short_cut.Save() def bulk_create_chrome(nums): for i in range(1,nums+1): create_chrome("深圳",i) if __name__ == '__main__': # create_chrome("北京",1) bulk_create_chrome(nums=3)
标签:cut,浏览器,chrome,create,short,google,path,快捷方式 From: https://www.cnblogs.com/knighterrant/p/17441861.html