How to get path of Start Menu's Programs directory?

前端 未结 3 428
故里飘歌
故里飘歌 2020-12-10 16:16

...for current user? for all users?

I\'m working an a small program which needs to create links in the start menu. Currently I\'m hardcoding like below, but it only

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 16:50

    I've heard of 2 ways of doing this. First:

    from win32com.shell import shell
    shell.SHGetSpecialFolderPath(0,shellcon.CSIDL_COMMON_STARTMENU)
    

    Second, using the WScript.Shell object (source : http://www.mail-archive.com/python-win32@python.org/msg00992.html):

    import win32com.client
    objShell = win32com.client.Dispatch("WScript.Shell")
    allUserProgramsMenu = objShell.SpecialFolders("AllUsersPrograms")
    userMenu = objShell.SpecialFolders("StartMenu")
    

    Another source: http://blogs.msdn.com/saveenr/archive/2005/12/28/creating-a-start-menu-shortcut-with-powershell-and-python.aspx

提交回复
热议问题