import os js='''var WSHShell=WScript.CreateObject("WScript.Shell"); var MyShortcut=WSHShell.CreateShortcut(WSHShell.SpecialFolders("Desktop")+"\\flauxtext.lnk"); MyShortcut.WorkingDirectory="C:\\"; MyShortcut.Hotkey="Ctrl+Alt+N"; MyShortcut.TargetPath="'''+os.path.join(os.path.dirname(__file__),'flauxtext.pyw')+'''"; MyShortcut.IconLocation="'''+os.path.join(os.path.dirname(__file__),'icon.ico')+'''"; if(WSHShell.Popup("Do you want a shortcut to flauxtext on your desktop?\\n\\n[If you select Yes, my hotkey will be Control + Alt + N.\\nIf this hotkey is already mapped to something else, you can change mine or its previous owner\'s hotkey.\\nI won\'t change either for you.]",0,"Hello, good sir knight!",36)==6){ //36=32+4=Question icon + Yes/No buttons; 6=Yes response MyShortcut.Save(); }''' fn=os.path.join(os.path.dirname(__file__),'flauxtext_desktop_icon.js') open(fn, 'w').write(js.replace('\\','\\\\').replace('\\\\n','\\n')) os.startfile(fn)