avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday May 25, 2024, 5:56 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: auto create .lnk shortcuts for all currently installed Windows Store Apps  (Read 12756 times)


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Coding Snack request
a script/tool that auto creates .lnk shortcuts for all currently installed Windows Store Apps.

Users of Mouser's Find And Run Robot (FARR) requested an easy way to launch Windows Store Apps. The problem is that those apps do not create .lnk shortcut files FARR can find when searching files and folders. Users can manually create .lnk shortcuts one by one. But an automated method would be more user friendly. A standalone tool could also be useful for people who don't use FARR.

Research done

1. syntax for .lnk shortcuts to Windows Store Apps

Windows Store Apps can  be run from .lnk shortcuts with a target that has this format
explorer.exe shell:Appsfolder\<AUMID>
where AUMID (Application User Model ID) is a special string for each app.
For example on my PC we can launch Windows Calculator with
explorer.exe shell:Appsfolder\Microsoft.WindowsCalculator_8wekyb3d8bbwe!App

2. Powershell command to get a list of AUMID
The Powershell command
returns a list with an App name and its associated App AUMID on each line.
More details here https://docs.microso...-of-an-installed-app

3. Making .lnk shortcuts programmatically
AutoHotkey has the command FileCreateShortcut, https://autohotkey.c...leCreateShortcut.htm

What has already been tried
I didn't find a working way to use AutoHotkey to run Powershell with the get-StartApps command and output the resulting list to a .txt file.
I get this error
'get-StartApps' is not recognized as the name of a cmdlet

Instead of banging my non-powershell experienced head more against powershell error message walls, perhaps someone else here can think of a quick fix or different solution, using AutoHotkey, Powershell or some other method?  :)


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
Simple Powershell script, it'll create an "Installed-Apps" folder on the Desktop and populate it with shortcuts for installed ... err ... apps.

For this purpose it regards any AUMID that contains a ! and doesn't end in .exe as a valid app - as distinct from every program installed.

Run it from a Powershell console using: .\Apps2Shortcut.ps1

For some reason I couldn't get it to run from a shortcut but that's probably my fault.

You will probably get an error if you run the extracted script from the archive due to Execution Policy, there are 3 solutions:
  • Copy/Paste the script below as a new script
  • Mark the script as trusted, (it has a zone identifier in its ADS which marks it as not from the local machine)
  • Change your Execution Policy using Set-ExecutionPolicy

Standard Disclaimer: Works for me  :)

Code: PowerShell [Select]
  1. <#
  2.   Apps2Shortcut.ps1
  3. #>
  4. Function Create-Shortcut {
  5.   param (
  6.     [string]$name,
  7.     [string]$aumid
  8.   )
  9.   # Create a Shortcut with Windows PowerShell
  10.   $WScriptShell = New-Object -ComObject WScript.Shell
  11.   $Shortcut = $WScriptShell.CreateShortcut($name)
  12.   $Shortcut.TargetPath = "$env:SystemRoot\explorer.exe"
  13.   $Shortcut.Arguments = "shell:Appsfolder\$($aumid)"
  14.   $Shortcut.Save()
  15. }
  17. $DesktopPath = [Environment]::GetFolderPath("Desktop")
  19. if (!(Test-Path "$($DesktopPath)\Installed-Apps")) {
  20.   New-Item "$($DesktopPath)\Installed-Apps" -ItemType Directory | Out-Null
  21. }
  23. $apps = (Get-StartApps)
  24. for ($i = 0; $i -lt $apps.Count; $i++) {
  25.   if (($apps[$i].AppID).contains("!") -and (($apps[$i].AppID).Substring(($apps[$i].AppID).Length - 4) -ne '.exe')) {
  26.     Create-Shortcut "$($DesktopPath)\Installed-Apps\$($apps[$i].Name).lnk" $apps[$i].AppID
  27.   }
  28. }

Hopefully you'll end up with something like this:

2019-04-01 10_38_59.pngauto create .lnk shortcuts for all currently installed Windows Store Apps

To run a Powershell command from AHK you'll probably need to use: powershell.exe -C "Get-StartApps | Out-File D:\test.txt"

Use -C to run commands directly, -F to run a script.
« Last Edit: April 03, 2019, 02:37 PM by 4wd »


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Simple Powershell script

To get the script to work on my PC I had to do these things
- the multi line comments at the top gave errors, but changing /* and */ to <# and #> fixed that.
- run the cmd window as administrator
- add the Bypass argument, like so
powershell.exe -ExecutionPolicy Bypass -F C:\folder\Apps2Shortcut.ps1
Then it works and outputs .lnk shortcut files in the desktop folder "Installed-Apps". Nice!

But I can't get it to run within AutoHotkey, even as administrator. I've tried
Run powershell.exe -ExecutionPolicy Bypass -F C:\folder\Apps2Shortcut.ps1
Run powershell.exe -ExecutionPolicy Bypass -NoExit -F C:\folder\Apps2Shortcut.ps1
RunWait powershell.exe -ExecutionPolicy Bypass -NoExit -F C:\folder\Apps2Shortcut.ps1
and some other variations without success. Similarly, this and variations of it also do not work
Run powershell.exe -ExecutionPolicy Bypass -C "Get-StartApps | Out-File C:\folder\test.txt"
I don't have to use AutoHotkey of course. But remaining issues I'm trying to solve are
1. how to automatically run the script at least every time Windows starts, to keep the .lnk files up to date?
2. how to make it easy for end users (ideally not running as administrator) to set this up once and for all?
And also
3. is there some way to add the matching icons to the shortcuts?

This handles issue 1 above. Run the AutoHotkey script as administrator creates a scheduled task that in turn on each logon runs the powershell script to create .lnk files.
RunWait schtasks /Create /SC ONLOGON /TN Apps2Shortcut /TR "powershell.exe -ExecutionPolicy Bypass -F C:\folder\Apps2Shortcut.ps1"
The same task can also be created manually (and deleted if no longer needed) through the Task Scheduler (win+I and search for "schedule tasks").
Not a very end-user friendly way to set this up though.

This Python solution works for me without running as administrator
I had to use Python 2. The .lnk shortcut files also get icons (issue 3 above).
Perhaps the approach there can be reproduced without Python.
« Last Edit: April 01, 2019, 11:03 AM by Nod5 »


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
To get the script to work on my PC I had to do these things
- the multi line comments at the top gave errors, but changing /* and */ to <# and #> fixed that.

Ooops, my bad, I added the comment after pasting into the post ... should've tested it.
I've updated the code/archive.
- run the cmd window as administrator
- add the Bypass argument, like so

Wasn't necessary if run from a PowerShell console, even just right-click on the script and choose Run with Powershell but you'd bump up against the ExecutionPolicy restriction - which does get to be a real PITA sometimes.  In theory you can right-click->Properties and select something like Trust this file under the Security tab ... but I haven't seen it for awhile so I may be mis-remembering.

Shouldn't need Admin privileges since you're only writing to a directory that the user owns anyway ... just tried it here, no Admin required, just had to answer '(Y)es' to the ExecutionPolicy question that pops up.

The same task can also be created manually (and deleted if no longer needed) through the Task Scheduler (win+I and search for "schedule tasks").
Not a very end-user friendly way to set this up though.

Perhaps this post which shows setting/deleting a scheduled task in Powershell may help?

Give the task a static name and have the script just check if it's there at each run using schtasks /query <taskname>, implement if it isn't and have an optional argument to the script Apps2Shortcut.ps1 -Remove to remove it if the task is no longer required.
« Last Edit: April 01, 2019, 12:07 PM by 4wd »


  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,906
    • View Profile
    • Mouser's Software Zone on
    • Read more about this member.
    • Donate to Member
Very cool -- thank you for this  :up: :up:


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
Changed it a little w.r.t. what's regarded as an App.


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
This Python solution works for me without running as administrator
I had to use Python 2. The .lnk shortcut files also get icons (issue 3 above).
Perhaps the approach there can be reproduced without Python.

Just as a matter of interest, what is the shortcut Target that is generated by the above script?

Does it use explorer.exe shell:.... or does it resolve to the executable?

ie. It would be easy to add an icon to the shortcut but you'd need to resolve to the executable to fetch it.
« Last Edit: April 04, 2019, 06:31 AM by 4wd »


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
what is the shortcut Target that is generated by the above script?
Does it use explorer.exe shell:.... or does it resolve to the executable?
It isn't an ordinary .lnk shortcut file. The target field is greyed out in the file properties window. This is for Calculator app:


The target field contains only Microsoft.WindowsCalculator_8wekyb3d8bbwe!App, so the Explorer.exe shell:Appsfolder\ part from the regular shortcuts isn't there.

When I open the .lnk in HxD Hex Editor it decodes to among other things this path string
C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1902.42.0_x64__8wekyb3d8bbwe
which is a protected folder that contains these files
and subfolders
The .lnk file also contains strings that are paths to .png icons files in the Assets subfolder above.

I'm not familiar enough with the Windows API and python stuff in the StackOverflow code to understand what it is doing line by line.


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
I thought it might be looking at the PNG images in the Assets folder, I can get the path and executable via PowerShell but none of the executables contain an icon according to Windows.

Trouble is working out which PNG to use since due to standards the names aren't standard.

The PowerShell commands to get all the info pertaining to Apps are:

Also, the manifest for some apps, (eg. Photos & Video Editor) is the same since the only difference is the entry point into the app which you can see in the shortcuts my script above created:

Photos:        C:\Windows\explorer.exe shell:Appsfolder\Microsoft.Windows.Photos_8wekyb3d8bbwe!App
Video Editor: C:\Windows\explorer.exe shell:Appsfolder\Microsoft.Windows.Photos_8wekyb3d8bbwe!SecondaryEntry

Below is a small script that gets the App name, ID, path, executable, and logo:
Code: PowerShell [Select]
  1. cls
  2. $apps = (Get-StartApps)
  3. #$apps | Get-Member
  4. $j = 0
  5. for ($i = 0; $i -lt $apps.Count; $i++) {
  6.   if (($apps[$i].AppID).Contains("!")) {
  7.     $j++
  8.     Write-Host "Name: $($apps[$i].Name)"
  9.     Write-Host "  AppID: $($apps[$i].AppID)"
  10.     $package = Get-AppxPackage -Name ($apps[$i].AppID).SubString(0, ($apps[$i].AppID).IndexOf("_"))
  11. #    if ($package.SignatureKind -eq "Store") {
  12. #      $package | Get-Member
  13.       Write-Host "  InstallLocation: $($package.InstallLocation)"
  14.       $manifests = Get-AppxPackageManifest -Package $package
  15.       foreach ($manifest in $manifests) {
  16.         foreach($app in $manifest.Package.Applications.Application) {
  17. #          $app | Get-Member
  18. #          Write-Host "  Id: $($app.Id)"
  19.           Write-Host "  Executable: $($app.Executable)"
  20.           Write-Host "  Logo: $($manifest.Package.Properties.Logo)"
  21.         }
  22.       }
  23. #    }
  24.   }
  25. }
  26. Write-Host $j

The remarked lines are just me experimenting with trying to narrow down the list.

Code: Text [Select]
  1. Name: GetThemAll - Video Downlaoder
  2.   AppID: NimbusWeb.GetThemAll-VideoDownlaoder_p5fjnfwkc9ns0!App
  3.   InstallLocation: C:\Program Files\WindowsApps\NimbusWeb.GetThemAll-VideoDownlaoder_2.3.2.0_x64__p5fjnfwkc9ns0
  4.   Executable: NativeMessagingFFMPEG.exe
  5.   Logo: Assets\StoreLogo.png
  6. Name: Microsoft Edge
  7.   AppID: Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge
  8.   InstallLocation: C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe
  9.   Executable: MicrosoftEdge.exe
  10.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  11.   Executable: MicrosoftEdgeCP.exe
  12.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  13.   Executable: MicrosoftEdgeCP.exe
  14.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  15.   Executable: MicrosoftEdgeCP.exe
  16.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  17.   Executable: MicrosoftPdfReader.exe
  18.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  19. Name: Connect
  20.   AppID: Microsoft.PPIProjection_cw5n1h2txyewy!Microsoft.PPIProjection
  21.   InstallLocation: C:\Windows\SystemApps\Microsoft.PPIProjection_cw5n1h2txyewy
  22.   Executable: Receiver.exe
  23.   Logo: Assets\StoreLogo.png
  24. Name: Cortana
  25.   AppID: Microsoft.Windows.Cortana_cw5n1h2txyewy!CortanaUI
  26.   InstallLocation: C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy
  27.   Executable: SearchUI.exe
  28.   Logo: Assets\Icons\MediumTile.png
  29.   Executable: RemindersShareTargetApp.exe
  30.   Logo: Assets\Icons\MediumTile.png
  31.   Executable: Cain.exe
  32.   Logo: Assets\Icons\MediumTile.png
  33. Name: Mixed Reality Portal
  34.   AppID: Microsoft.Windows.HolographicFirstRun_cw5n1h2txyewy!App
  35.   InstallLocation: C:\Windows\SystemApps\Microsoft.Windows.HolographicFirstRun_cw5n1h2txyewy
  36.   Executable: MixedRealityPortal.exe
  37.   Logo: Assets\MixedRealityPortalMedTile.png
  38. Name: Windows Defender Security Centre
  39.   AppID: Microsoft.Windows.SecHealthUI_cw5n1h2txyewy!SecHealthUI
  40.   InstallLocation: C:\Windows\SystemApps\Microsoft.Windows.SecHealthUI_cw5n1h2txyewy
  41.   Executable: SecHealthUI.exe
  42.   Logo: Assets\DefenderAppSplashScreen.scale-400.png
  43. Name: Settings
  44.   AppID: windows.immersivecontrolpanel_cw5n1h2txyewy!
  45.   InstallLocation: C:\Windows\ImmersiveControlPanel
  46.   Executable: SystemSettings.exe
  47.   Logo: images\logo.png
  48. Name: Print 3D
  49.   AppID: Microsoft.Print3D_8wekyb3d8bbwe!App
  50.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Print3D_3.1.2612.0_x64__8wekyb3d8bbwe
  51.   Executable: Print3D.exe
  52.   Logo: Assets\manifestAssets\StoreLogo.png
  53. Name: Get Help
  54.   AppID: Microsoft.GetHelp_8wekyb3d8bbwe!App
  55.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.GetHelp_10.1706.12921.0_x64__8wekyb3d8bbwe
  56.   Executable: GetHelp.exe
  57.   Logo: Assets\Logo.png
  58. Name: Maps
  59.   AppID: Microsoft.WindowsMaps_8wekyb3d8bbwe!App
  60.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsMaps_5.1812.10071.0_x64__8wekyb3d8bbwe
  61.   Executable: Maps.exe
  62.   Logo: Assets\AppTiles\MapsStoreLogo.png
  63. Name: Messaging
  64.   AppID: Microsoft.Messaging_8wekyb3d8bbwe!x27e26f40ye031y48a6yb130yd1f20388991ax
  65.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Messaging_4.1901.10241.0_x64__8wekyb3d8bbwe
  66.   Executable: MessagingApplication.exe
  67.   Logo: Assets\StoreLogo.png
  68. Name: Calculator
  69.   AppID: Microsoft.WindowsCalculator_8wekyb3d8bbwe!App
  70.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1812.10048.0_x64__8wekyb3d8bbwe
  71.   Executable: Calculator.exe
  72.   Logo: Assets\CalculatorStoreLogo.png
  73. Name: 3D Viewer
  74.   AppID: Microsoft.Microsoft3DViewer_8wekyb3d8bbwe!Microsoft.Microsoft3DViewer
  75.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Microsoft3DViewer_6.1903.4012.0_x64__8wekyb3d8bbwe
  76.   Executable: 3DViewer.exe
  77.   Logo: Assets\StoreLogo.png
  78. Name: OneNote
  79.   AppID: Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim
  80.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Office.OneNote_16001.11425.20094.0_x64__8wekyb3d8bbwe
  81.   Executable: onenoteim.exe
  82.   Logo: images\OneNoteAppList.png
  83. Name: Aussie TV FTW!
  84.   AppID: 55758OcelotSoft.AussieTVFTW_jzcqt2s08q53y!App
  85.   InstallLocation: C:\Program Files\WindowsApps\55758OcelotSoft.AussieTVFTW_1.8.0.0_x64__jzcqt2s08q53y
  86.   Executable: AussieTV.exe
  87.   Logo: Assets\StoreLogo.png
  88. Name: Alarms & Clock
  89.   AppID: Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
  90.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsAlarms_10.1902.633.0_x64__8wekyb3d8bbwe
  91.   Executable: Time.exe
  92.   Logo: Assets\AlarmsStoreLogo.png
  93. Name: Paint 3D
  94.   AppID: Microsoft.MSPaint_8wekyb3d8bbwe!Microsoft.MSPaint
  95.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.MSPaint_5.1811.20017.0_x64__8wekyb3d8bbwe
  96.   Executable: PaintStudio.View.exe
  97.   Logo: Assets\Logos\StoreLogo\PaintApplist.png
  98. Name: OverDrive - Library eBooks & Audiobooks
  99.   AppID: 2FA138F6.OverDriveMediaConsole_daecb9042jmvt!App
  100.   InstallLocation: C:\Program Files\WindowsApps\2FA138F6.OverDriveMediaConsole_3.8.0.5_neutral__daecb9042jmvt
  101.   Executable: MediaConsole.Win8.exe
  102.   Logo: Assets\StoreLogo.png
  103. Name: Voice Recorder
  104.   AppID: Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe!App
  105.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsSoundRecorder_10.1902.633.0_x64__8wekyb3d8bbwe
  106.   Executable: SoundRec.exe
  107.   Logo: Assets\VoiceRecorderStoreLogo.png
  108. Name: Microsoft Store
  109.   AppID: Microsoft.WindowsStore_8wekyb3d8bbwe!App
  110.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsStore_11811.1001.27.0_x64__8wekyb3d8bbwe
  111.   Executable: WinStore.App.exe
  112.   Logo: Assets\AppTiles\StoreLogo.png
  113. Name: Photos
  114.   AppID: Microsoft.Windows.Photos_8wekyb3d8bbwe!App
  115.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Windows.Photos_2019.19021.18010.0_x64__8wekyb3d8bbwe
  116.   Executable: Microsoft.Photos.exe
  117.   Logo: Assets\PhotosStoreLogo.png
  118.   Executable: VideoProjectsLauncher.exe
  119.   Logo: Assets\PhotosStoreLogo.png
  120. Name: Video editor
  121.   AppID: Microsoft.Windows.Photos_8wekyb3d8bbwe!SecondaryEntry
  122.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Windows.Photos_2019.19021.18010.0_x64__8wekyb3d8bbwe
  123.   Executable: Microsoft.Photos.exe
  124.   Logo: Assets\PhotosStoreLogo.png
  125.   Executable: VideoProjectsLauncher.exe
  126.   Logo: Assets\PhotosStoreLogo.png
  127. Name: Camera
  128.   AppID: Microsoft.WindowsCamera_8wekyb3d8bbwe!App
  129.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsCamera_2019.124.60.0_x64__8wekyb3d8bbwe
  130.   Executable: WindowsCamera.exe
  131.   Logo: Assets\WindowsIcons\StoreLogo.png
  132. 23

I can try and find some correlation regarding the image they use from the Assets folder since some folders don't contain images with the same name as other Assets folders - there maybe be something in the manifest I can work from.

EDIT: Think I found where the image is specified in the manifest - can you upload a couple or so of the icons the Python script created?
« Last Edit: April 04, 2019, 03:46 PM by 4wd »


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Thanks for continuing this detective work  :)

The Python script doesn't create any icon image files per se. In the hex editor the .lnk contains these relative path strings

The matching Assets folder has for each of the above multiple .png files with the same start name then a dot and some size/color specification. For example
It looks like one or other of the .png that start with CalculatorAppList is used for the icon for the .lnk when I view it in Explorer.

But the .png in Assets are black and white while the .lnk icon is white with blue background. (But maybe the blue is dependent on some Windows theme?)

I examined a few more of the python generated .lnk in the hex editor but can't see any simple consistent pattern in the name of the .png filenames.

Anyway, recreating the look and feel of the icons in the python generated shortcuts involves both finding the right .png to use and transforming its color.

I attach one of the .png files and an overview screenshot from Explorer with many of the image files.

Shortcut files are more complicated that one might have though :o


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
Sorry, meant to say upload a couple of the shortcut .lnk files not icons.  :-[

Problem I'm having is trying to get PowerShell to accept what is a virtual path, the FOLDERID_AppsFolder in the python script.


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Ok, here are .lnk files for Calculator and Xbox as generated by the StackOverflow python script.

edit: I compared the python generated Calculator shortcut with one made through the context menu in the AppsFolder (win+R and then shell:AppsFolder, right click Calculator, "create shortcut"). The two files are identical except for block (decimal)number 22, which has the value 00 in the python generated file and 08 in the other.
« Last Edit: April 08, 2019, 07:29 AM by Nod5 »


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
Not getting any headway with this, I can't seem to find info on using FOLDERID_AppsFolder in PowerShell, possibly because it's a Virtual Folder.

For other KNOWNFOLDERID values this doesn't seem to be a problem, eg. here's a script below that will get the real folder for KNOWNFOLDERID but it doesn't work for Virtual Folders - as is shown by it printing nothing for AppsFolder and AppUpdates.

So atm, I don't know what else to try to get close to the same result as the Python script.

Code: PowerShell [Select]
  1. #
  2. Add-Type @"
  4.    using System;
  5.    using System.Runtime.InteropServices;
  7.    public static class KnownFolder
  8.    {
  9.        public static readonly Guid AddNewPrograms = new Guid( "de61d971-5ebc-4f02-a3a9-6c82895e5c04" );
  10.        public static readonly Guid AdminTools = new Guid( "724EF170-A42D-4FEF-9F26-B60E846FBA4F" );
  11.        public static readonly Guid AppsFolder = new Guid( "1e87508d-89c2-42f0-8a7e-645a0f50ca58" );
  12.        public static readonly Guid AppUpdates = new Guid( "a305ce99-f527-492b-8b1a-7e76fa98d6e4" );
  13.        public static readonly Guid CDBurning = new Guid( "9E52AB10-F80D-49DF-ACB8-4330F5687855" );
  14.        public static readonly Guid ChangeRemovePrograms = new Guid( "df7266ac-9274-4867-8d55-3bd661de872d" );
  15.        public static readonly Guid CommonAdminTools = new Guid( "D0384E7D-BAC3-4797-8F14-CBA229B392B5" );
  16.        public static readonly Guid CommonOEMLinks = new Guid( "C1BAE2D0-10DF-4334-BEDD-7AA20B227A9D" );
  17.        public static readonly Guid CommonPrograms = new Guid( "0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8" );
  18.        public static readonly Guid CommonStartMenu = new Guid( "A4115719-D62E-491D-AA7C-E74B8BE3B067" );
  19.        public static readonly Guid CommonStartup = new Guid( "82A5EA35-D9CD-47C5-9629-E15D2F714E6E" );
  20.        public static readonly Guid CommonTemplates = new Guid( "B94237E7-57AC-4347-9151-B08C6C32D1F7" );
  21.        public static readonly Guid ComputerFolder = new Guid( "0AC0837C-BBF8-452A-850D-79D08E667CA7" );
  22.        public static readonly Guid ConflictFolder = new Guid( "4bfefb45-347d-4006-a5be-ac0cb0567192" );
  23.        public static readonly Guid ConnectionsFolder = new Guid( "6F0CD92B-2E97-45D1-88FF-B0D186B8DEDD" );
  24.        public static readonly Guid Contacts = new Guid( "56784854-C6CB-462b-8169-88E350ACB882" );
  25.        public static readonly Guid ControlPanelFolder = new Guid( "82A74AEB-AEB4-465C-A014-D097EE346D63" );
  26.        public static readonly Guid Cookies = new Guid( "2B0F765D-C0E9-4171-908E-08A611B84FF6" );
  27.        public static readonly Guid Desktop = new Guid( "B4BFCC3A-DB2C-424C-B029-7FE99A87C641" );
  28.        public static readonly Guid Documents = new Guid( "FDD39AD0-238F-46AF-ADB4-6C85480369C7" );
  29.        public static readonly Guid Downloads = new Guid( "374DE290-123F-4565-9164-39C4925E467B" );
  30.        public static readonly Guid Favorites = new Guid( "1777F761-68AD-4D8A-87BD-30B759FA33DD" );
  31.        public static readonly Guid Fonts = new Guid( "FD228CB7-AE11-4AE3-864C-16F3910AB8FE" );
  32.        public static readonly Guid Games = new Guid( "CAC52C1A-B53D-4edc-92D7-6B2E8AC19434" );
  33.        public static readonly Guid GameTasks = new Guid( "054FAE61-4DD8-4787-80B6-090220C4B700" );
  34.        public static readonly Guid History = new Guid( "D9DC8A3B-B784-432E-A781-5A1130A75963" );
  35.        public static readonly Guid InternetCache = new Guid( "352481E8-33BE-4251-BA85-6007CAEDCF9D" );
  36.        public static readonly Guid InternetFolder = new Guid( "4D9F7874-4E0C-4904-967B-40B0D20C3E4B" );
  37.        public static readonly Guid Links = new Guid( "bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968" );
  38.        public static readonly Guid LocalAppData = new Guid( "F1B32785-6FBA-4FCF-9D55-7B8E7F157091" );
  39.        public static readonly Guid LocalAppDataLow = new Guid( "A520A1A4-1780-4FF6-BD18-167343C5AF16" );
  40.        public static readonly Guid LocalizedResourcesDir = new Guid( "2A00375E-224C-49DE-B8D1-440DF7EF3DDC" );
  41.        public static readonly Guid Music = new Guid( "4BD8D571-6D19-48D3-BE97-422220080E43" );
  42.        public static readonly Guid NetHood = new Guid( "C5ABBF53-E17F-4121-8900-86626FC2C973" );
  43.        public static readonly Guid NetworkFolder = new Guid( "D20BEEC4-5CA8-4905-AE3B-BF251EA09B53" );
  44.        public static readonly Guid OriginalImages = new Guid( "2C36C0AA-5812-4b87-BFD0-4CD0DFB19B39" );
  45.        public static readonly Guid PhotoAlbums = new Guid( "69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C" );
  46.        public static readonly Guid Pictures = new Guid( "33E28130-4E1E-4676-835A-98395C3BC3BB" );
  47.        public static readonly Guid Playlists = new Guid( "DE92C1C7-837F-4F69-A3BB-86E631204A23" );
  48.        public static readonly Guid PrintersFolder = new Guid( "76FC4E2D-D6AD-4519-A663-37BD56068185" );
  49.        public static readonly Guid PrintHood = new Guid( "9274BD8D-CFD1-41C3-B35E-B13F55A758F4" );
  50.        public static readonly Guid Profile = new Guid( "5E6C858F-0E22-4760-9AFE-EA3317B67173" );
  51.        public static readonly Guid ProgramData = new Guid( "62AB5D82-FDC1-4DC3-A9DD-070D1D495D97" );
  52.        public static readonly Guid ProgramFiles = new Guid( "905e63b6-c1bf-494e-b29c-65b732d3d21a" );
  53.        public static readonly Guid ProgramFilesX64 = new Guid( "6D809377-6AF0-444b-8957-A3773F02200E" );
  54.        public static readonly Guid ProgramFilesX86 = new Guid( "7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E" );
  55.        public static readonly Guid ProgramFilesCommon = new Guid( "F7F1ED05-9F6D-47A2-AAAE-29D317C6F066" );
  56.        public static readonly Guid ProgramFilesCommonX64 = new Guid( "6365D5A7-0F0D-45E5-87F6-0DA56B6A4F7D" );
  57.        public static readonly Guid ProgramFilesCommonX86 = new Guid( "DE974D24-D9C6-4D3E-BF91-F4455120B917" );
  58.        public static readonly Guid Programs = new Guid( "A77F5D77-2E2B-44C3-A6A2-ABA601054A51" );
  59.        public static readonly Guid Public = new Guid( "DFDF76A2-C82A-4D63-906A-5644AC457385" );
  60.        public static readonly Guid PublicDesktop = new Guid( "C4AA340D-F20F-4863-AFEF-F87EF2E6BA25" );
  61.        public static readonly Guid PublicDocuments = new Guid( "ED4824AF-DCE4-45A8-81E2-FC7965083634" );
  62.        public static readonly Guid PublicDownloads = new Guid( "3D644C9B-1FB8-4f30-9B45-F670235F79C0" );
  63.        public static readonly Guid PublicGameTasks = new Guid( "DEBF2536-E1A8-4c59-B6A2-414586476AEA" );
  64.        public static readonly Guid PublicMusic = new Guid( "3214FAB5-9757-4298-BB61-92A9DEAA44FF" );
  65.        public static readonly Guid PublicPictures = new Guid( "B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5" );
  66.        public static readonly Guid PublicVideos = new Guid( "2400183A-6185-49FB-A2D8-4A392A602BA3" );
  67.        public static readonly Guid QuickLaunch = new Guid( "52a4f021-7b75-48a9-9f6b-4b87a210bc8f" );
  68.        public static readonly Guid Recent = new Guid( "AE50C081-EBD2-438A-8655-8A092E34987A" );
  69.        public static readonly Guid RecycleBinFolder = new Guid( "B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC" );
  70.        public static readonly Guid ResourceDir = new Guid( "8AD10C31-2ADB-4296-A8F7-E4701232C972" );
  71.        public static readonly Guid RoamingAppData = new Guid( "3EB685DB-65F9-4CF6-A03A-E3EF65729F3D" );
  72.        public static readonly Guid SampleMusic = new Guid( "B250C668-F57D-4EE1-A63C-290EE7D1AA1F" );
  73.        public static readonly Guid SamplePictures = new Guid( "C4900540-2379-4C75-844B-64E6FAF8716B" );
  74.        public static readonly Guid SamplePlaylists = new Guid( "15CA69B3-30EE-49C1-ACE1-6B5EC372AFB5" );
  75.        public static readonly Guid SampleVideos = new Guid( "859EAD94-2E85-48AD-A71A-0969CB56A6CD" );
  76.        public static readonly Guid SavedGames = new Guid( "4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4" );
  77.        public static readonly Guid SavedSearches = new Guid( "7d1d3a04-debb-4115-95cf-2f29da2920da" );
  78.        public static readonly Guid SEARCH_CSC = new Guid( "ee32e446-31ca-4aba-814f-a5ebd2fd6d5e" );
  79.        public static readonly Guid SEARCH_MAPI = new Guid( "98ec0e18-2098-4d44-8644-66979315a281" );
  80.        public static readonly Guid SearchHome = new Guid( "190337d1-b8ca-4121-a639-6d472d16972a" );
  81.        public static readonly Guid SendTo = new Guid( "8983036C-27C0-404B-8F08-102D10DCFD74" );
  82.        public static readonly Guid SidebarDefaultParts = new Guid( "7B396E54-9EC5-4300-BE0A-2482EBAE1A26" );
  83.        public static readonly Guid SidebarParts = new Guid( "A75D362E-50FC-4fb7-AC2C-A8BEAA314493" );
  84.        public static readonly Guid StartMenu = new Guid( "625B53C3-AB48-4EC1-BA1F-A1EF4146FC19" );
  85.        public static readonly Guid Startup = new Guid( "B97D20BB-F46A-4C97-BA10-5E3608430854" );
  86.        public static readonly Guid SyncManagerFolder = new Guid( "43668BF8-C14E-49B2-97C9-747784D784B7" );
  87.        public static readonly Guid SyncResultsFolder = new Guid( "289a9a43-be44-4057-a41b-587a76d7e7f9" );
  88.        public static readonly Guid SyncSetupFolder = new Guid( "0F214138-B1D3-4a90-BBA9-27CBC0C5389A" );
  89.        public static readonly Guid System = new Guid( "1AC14E77-02E7-4E5D-B744-2EB1AE5198B7" );
  90.        public static readonly Guid SystemX86 = new Guid( "D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27" );
  91.        public static readonly Guid Templates = new Guid( "A63293E8-664E-48DB-A079-DF759E0509F7" );
  92.        public static readonly Guid TreeProperties = new Guid( "5b3749ad-b49f-49c1-83eb-15370fbd4882" );
  93.        public static readonly Guid UserProfiles = new Guid( "0762D272-C50A-4BB0-A382-697DCD729B80" );
  94.        public static readonly Guid UsersFiles = new Guid( "f3ce0f7c-4901-4acc-8648-d5d44b04ef8f" );
  95.        public static readonly Guid Videos = new Guid( "18989B1D-99B5-455B-841C-AB7C74E4DDFC" );
  96.        public static readonly Guid Windows = new Guid( "F38BF404-1D43-42F2-9305-67DE0B28FC23" );
  97.    }
  99.    public class shell32
  100.    {
  101.        [DllImport("shell32.dll")]
  102.        private static extern int SHGetKnownFolderPath(
  103.             [MarshalAs(UnmanagedType.LPStruct)]
  104.             Guid rfid,
  105.             uint dwFlags,
  106.             IntPtr hToken,
  107.             out IntPtr pszPath
  108.         );
  110.         public static string GetKnownFolderPath(Guid rfid)
  111.         {
  112.            IntPtr pszPath;
  113.            if (SHGetKnownFolderPath(rfid, 0, IntPtr.Zero, out pszPath) != 0)
  114.                return ""; // add whatever error handling you fancy
  115.            string path = Marshal.PtrToStringUni(pszPath);
  116.            Marshal.FreeCoTaskMem(pszPath);
  117.            return path;
  118.         }
  119.    }
  121. "@
  123. [shell32]::GetKnownFolderPath([KnownFolder]::Documents)
  124. [shell32]::GetKnownFolderPath([KnownFolder]::AppsFolder)
  125. [shell32]::GetKnownFolderPath([KnownFolder]::AppUpdates)
  126. [shell32]::GetKnownFolderPath([KnownFolder]::UserProfiles)