2

How do I open an executable through powershell inside of C:\Program Files\WindowsApps\some_app_folder\*.exe?

When I run the following powershell command:

Start-Process -FilePath '.\Calculator.exe'


#full path example: C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1903.21.0_x64__8wekyb3d8bbwe\Calculator.exe

I get this error: "This command cannot be run due to the error: Access is denied"

Observations:

  • If I do a search for Calculator inside of Windows search and I hit enter, I'm able to open up the app this way via Windows search.

Is there a way I can run the process as a different user who can open this file?

Manual Workaround:

I could just grab the specific URI shortcut that launches the app from each windows app by looking at each of the Windows app C:\Program Files\WindowsApps\some_app\AppxManifest.xml file. For example, I could launch a few of the windows apps this way:

# Powershell ...you can also run this inside "Run as" without `Start-Process
Start-Process calculator:
Start-Process ms-photos:
Start-Process Spotify:

But I'm trying to avoid this and simply use the .exe file. Grepping each manifest wouldn't work to well since an AppxManifest can have several or even up to a dozen URI shortcuts defined for launching the app (some go to different pages in the app). For example the Windows Weather app has:

 <uap:Extension Category="windows.protocol">
          <uap:Protocol Name="msnweather"/>
        </uap:Extension>
        <uap:Extension Category="windows.protocol">
          <uap:Protocol Name="bingweather"/>
        </uap:Extension>

I would need to manually create a blacklist in my script of what URI shortcut to keep or exclude.

GOAL:

  • I'd like to just open the .exe files for the windows app, hopefully without changing a user's registry files.

My use case:

I'm collecting the path to each .exe file for each windows app so I could later create a list of Windows Apps to display to a user in an app. The user would then be able to click the app and have it's associated .exe file open.


1

1 Answer 1

2

They are all listed under HKCR.

EG

HKEY_CLASSES_ROOT\bingweather

Shows URL:bingweather

Same with calculator. Although Calc.exe in System32 starts Calculator.

so these must be run via shellexecute. So if in CMD you need to use the Start command.

start calculator://
start bingweather://

Etc

This command will list them all but it also gets some other keys.

@For /f "tokens=1* delims=" %%A in ('reg query HKCR /f "URL:*" /s /d ^| findstr /c:"URL:" ^| findstr /v /c:"URL: " ^| Sort') Do @Echo %%A %%B
pause

EG

(Default)    REG_SZ    URL:armodelviewing
(Default)    REG_SZ    URL:Available Networks Protocol
(Default)    REG_SZ    URL:bingfinance
(Default)    REG_SZ    URL:bingmoney
(Default)    REG_SZ    URL:bingnews
(Default)    REG_SZ    URL:bingsports
(Default)    REG_SZ    URL:bingweather
(Default)    REG_SZ    URL:calculator
(Default)    REG_SZ    URL:callto
(Default)    REG_SZ    URL:clientx
(Default)    REG_SZ    URL:com.microsoft.3dviewer
(Default)    REG_SZ    URL:com.microsoft.builder3d
(Default)    REG_SZ    URL:com.microsoft.print3d
(Default)    REG_SZ    URL:Devices Flow Connectable Devices Protocol
(Default)    REG_SZ    URL:Devices Flow Display Topology Protocol
(Default)    REG_SZ    URL:dlna-playsingle Protocol
(Default)    REG_SZ    URL:feedback-hub
(Default)    REG_SZ    URL:File Protocol
(Default)    REG_SZ    URL:File Transfer Protocol
(Default)    REG_SZ    URL:File Transfer Protocol
(Default)    REG_SZ    URL:http
(Default)    REG_SZ    URL:https
(Default)    REG_SZ    URL:HyperText Transfer Protocol
(Default)    REG_SZ    URL:HyperText Transfer Protocol with Privacy
(Default)    REG_SZ    URL:insiderhub
(Default)    REG_SZ    URL:LDAP Protocol
(Default)    REG_SZ    URL:LDAP Protocol
(Default)    REG_SZ    URL:mailto
(Default)    REG_SZ    URL:MailTo Protocol
(Default)    REG_SZ    URL:maps
(Default)    REG_SZ    URL:microsoft-edge
(Default)    REG_SZ    URL:microsoft-edge-holographic
(Default)    REG_SZ    URL:microsoft.windows.camera
(Default)    REG_SZ    URL:microsoft.windows.camera.multipicker
(Default)    REG_SZ    URL:microsoft.windows.camera.picker
(Default)    REG_SZ    URL:microsoft.windows.photos.crop
(Default)    REG_SZ    URL:microsoft.windows.photos.picker
(Default)    REG_SZ    URL:microsoft.windows.photos.search
(Default)    REG_SZ    URL:microsoft.windows.photos.videoedit
(Default)    REG_SZ    URL:microsoftmusic
(Default)    REG_SZ    URL:microsoftvideo
(Default)    REG_SZ    URL:MK Protocol
(Default)    REG_SZ    URL:mms Protocol
(Default)    REG_SZ    URL:mms Protocol
(Default)    REG_SZ    URL:ms-aad-brokerplugin
(Default)    REG_SZ    URL:ms-actioncenter
(Default)    REG_SZ    URL:ms-appinstaller
(Default)    REG_SZ    URL:ms-apprep
(Default)    REG_SZ    URL:ms-calculator
(Default)    REG_SZ    URL:ms-callrecording
(Default)    REG_SZ    URL:ms-chat
(Default)    REG_SZ    URL:ms-clock
(Default)    REG_SZ    URL:ms-contact-support
(Default)    REG_SZ    URL:ms-cortana
(Default)    REG_SZ    URL:ms-cortana-ainotebook
(Default)    REG_SZ    URL:ms-cxh
(Default)    REG_SZ    URL:ms-default-location
(Default)    REG_SZ    URL:ms-device-enrollment
(Default)    REG_SZ    URL:ms-drive-to
(Default)    REG_SZ    URL:ms-gamebarservices
(Default)    REG_SZ    URL:ms-gamingoverlay
(Default)    REG_SZ    URL:ms-get-started
(Default)    REG_SZ    URL:ms-getoffice
(Default)    REG_SZ    URL:ms-holographicfirstrun
(Default)    REG_SZ    URL:ms-inputapp
(Default)    REG_SZ    URL:ms-ipmessaging
(Default)    REG_SZ    URL:ms-lcrv
(Default)    REG_SZ    URL:ms-mobileplans
(Default)    REG_SZ    URL:ms-msdt
(Default)    REG_SZ    URL:ms-oobenetwork
(Default)    REG_SZ    URL:ms-paint
(Default)    REG_SZ    URL:ms-penworkspace
(Default)    REG_SZ    URL:ms-people
(Default)    REG_SZ    URL:ms-phone-companion
(Default)    REG_SZ    URL:ms-photos
(Default)    REG_SZ    URL:ms-playto-miracast
(Default)    REG_SZ    URL:ms-projection
(Default)    REG_SZ    URL:ms-quick-assist
(Default)    REG_SZ    URL:ms-retaildemo-launchbioenrollment
(Default)    REG_SZ    URL:ms-retaildemo-launchstart
(Default)    REG_SZ    URL:ms-settings
(Default)    REG_SZ    URL:ms-settings-airplanemode
(Default)    REG_SZ    URL:ms-settings-bluetooth
(Default)    REG_SZ    URL:ms-settings-cellular
(Default)    REG_SZ    URL:ms-settings-emailandaccounts
(Default)    REG_SZ    URL:ms-settings-language
(Default)    REG_SZ    URL:ms-settings-location
(Default)    REG_SZ    URL:ms-settings-lock
(Default)    REG_SZ    URL:ms-settings-mobilehotspot
(Default)    REG_SZ    URL:ms-settings-notifications
(Default)    REG_SZ    URL:ms-settings-power
(Default)    REG_SZ    URL:ms-settings-privacy
(Default)    REG_SZ    URL:ms-settings-proximity
(Default)    REG_SZ    URL:ms-settings-screenrotation
(Default)    REG_SZ    URL:ms-settings-wifi
(Default)    REG_SZ    URL:ms-settings-workplace
(Default)    REG_SZ    URL:ms-sttoverlay
(Default)    REG_SZ    URL:ms-taskswitcher
(Default)    REG_SZ    URL:ms-unistore-email
(Default)    REG_SZ    URL:ms-walk-to
(Default)    REG_SZ    URL:ms-wcrv
(Default)    REG_SZ    URL:ms-windows-search
(Default)    REG_SZ    URL:ms-windows-store
(Default)    REG_SZ    URL:ms-windows-store2
(Default)    REG_SZ    URL:ms-wpc
(Default)    REG_SZ    URL:ms-wpdrmv
(Default)    REG_SZ    URL:ms-xbl-3d8b930f
(Default)    REG_SZ    URL:msnews
(Default)    REG_SZ    URL:msnfinance
(Default)    REG_SZ    URL:msnmoney
(Default)    REG_SZ    URL:msnnews
(Default)    REG_SZ    URL:msnsports
(Default)    REG_SZ    URL:msnweather
(Default)    REG_SZ    URL:netflix
(Default)    REG_SZ    URL:onenote
(Default)    REG_SZ    URL:onenote-cmd
(Default)    REG_SZ    URL:outlookaccounts
(Default)    REG_SZ    URL:outlookcal
(Default)    REG_SZ    URL:outlookmail
(Default)    REG_SZ    URL:Play Single DLNA Item Protocol
(Default)    REG_SZ    URL:read
(Default)    REG_SZ    URL:RES Protocol
(Default)    REG_SZ    URL:RLogin Protocol
(Default)    REG_SZ    URL:sms
(Default)    REG_SZ    URL:snapfish
(Default)    REG_SZ    URL:tbauth
(Default)    REG_SZ    URL:tel
(Default)    REG_SZ    URL:Telnet Protocol
(Default)    REG_SZ    URL:TN3270 Protocol
(Default)    REG_SZ    URL:tripadvisor
(Default)    REG_SZ    URL:twitter
(Default)    REG_SZ    URL:Virtual Touchpad
(Default)    REG_SZ    URL:VMware Restricted VM Protocol
(Default)    REG_SZ    URL:VMware VMRC Protocol
(Default)    REG_SZ    URL:windows-feedback
(Default)    REG_SZ    URL:windows.tbauth
(Default)    REG_SZ    URL:windowsdefender
(Default)    REG_SZ    URL:xbls
(Default)    REG_SZ    URL:xbox
(Default)    REG_SZ    URL:xbox-arena
(Default)    REG_SZ    URL:xbox-captures
(Default)    REG_SZ    URL:xbox-friendfinder
(Default)    REG_SZ    URL:xbox-gamehub
(Default)    REG_SZ    URL:xbox-lfg
(Default)    REG_SZ    URL:xbox-network
(Default)    REG_SZ    URL:xbox-profile
(Default)    REG_SZ    URL:xbox-settings
(Default)    REG_SZ    URL:xbox-store
(Default)    REG_SZ    URL:xbox-tcui
(Default)    REG_SZ    URL:xboxgames
(Default)    REG_SZ    URL:xboxliveapp-1297287741
(Default)    REG_SZ    URL:xboxmusic
(Default)    REG_SZ    URL:zune

Also you can open folders, this open Temp Internet Files.

start shell:cache

To generate

@For /f "tokens=1* delims=" %%A in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions /f name /v name /s ^| findstr /c:"Name" ^| Sort') Do @Echo %%A
pause

This is the list, for ones with spaces use start "" "shell:3d objects"

Name    REG_SZ    3D Objects
Name    REG_SZ    AccountPictures
Name    REG_SZ    AddNewProgramsFolder
Name    REG_SZ    Administrative Tools
Name    REG_SZ    AppData
Name    REG_SZ    AppDataDesktop
Name    REG_SZ    AppDataDocuments
Name    REG_SZ    AppDataFavorites
Name    REG_SZ    AppDataProgramData
Name    REG_SZ    Application Shortcuts
Name    REG_SZ    AppMods
Name    REG_SZ    AppsFolder
Name    REG_SZ    AppUpdatesFolder
Name    REG_SZ    Cache
Name    REG_SZ    Camera Roll
Name    REG_SZ    CameraRollLibrary
Name    REG_SZ    Captures
Name    REG_SZ    CD Burning
Name    REG_SZ    ChangeRemoveProgramsFolder
Name    REG_SZ    Common Administrative Tools
Name    REG_SZ    Common AppData
Name    REG_SZ    Common Desktop
Name    REG_SZ    Common Documents
Name    REG_SZ    Common Programs
Name    REG_SZ    Common Start Menu
Name    REG_SZ    Common Start Menu Places
Name    REG_SZ    Common Startup
Name    REG_SZ    Common Templates
Name    REG_SZ    CommonDownloads
Name    REG_SZ    CommonMusic
Name    REG_SZ    CommonPictures
Name    REG_SZ    CommonRingtones
Name    REG_SZ    CommonVideo
Name    REG_SZ    ConflictFolder
Name    REG_SZ    ConnectionsFolder
Name    REG_SZ    Contacts
Name    REG_SZ    ControlPanelFolder
Name    REG_SZ    Cookies
Name    REG_SZ    CredentialManager
Name    REG_SZ    CryptoKeys
Name    REG_SZ    CSCFolder
Name    REG_SZ    Desktop
Name    REG_SZ    Development Files
Name    REG_SZ    Device Metadata Store
Name    REG_SZ    DocumentsLibrary
Name    REG_SZ    Downloads
Name    REG_SZ    DpapiKeys
Name    REG_SZ    Favorites
Name    REG_SZ    Fonts
Name    REG_SZ    GameTasks
Name    REG_SZ    History
Name    REG_SZ    HomeGroupCurrentUserFolder
Name    REG_SZ    HomeGroupFolder
Name    REG_SZ    ImplicitAppShortcuts
Name    REG_SZ    InternetFolder
Name    REG_SZ    Libraries
Name    REG_SZ    Links
Name    REG_SZ    Local AppData
Name    REG_SZ    Local Documents
Name    REG_SZ    Local Downloads
Name    REG_SZ    Local Music
Name    REG_SZ    Local Pictures
Name    REG_SZ    Local Videos
Name    REG_SZ    LocalAppDataLow
Name    REG_SZ    LocalizedResourcesDir
Name    REG_SZ    MAPIFolder
Name    REG_SZ    MusicLibrary
Name    REG_SZ    My Music
Name    REG_SZ    My Pictures
Name    REG_SZ    My Video
Name    REG_SZ    MyComputerFolder
Name    REG_SZ    NetHood
Name    REG_SZ    NetworkPlacesFolder
Name    REG_SZ    OEM Links
Name    REG_SZ    OneDrive
Name    REG_SZ    OneDriveCameraRoll
Name    REG_SZ    OneDriveDocuments
Name    REG_SZ    OneDriveMusic
Name    REG_SZ    OneDrivePictures
Name    REG_SZ    Original Images
Name    REG_SZ    Personal
Name    REG_SZ    PhotoAlbums
Name    REG_SZ    PicturesLibrary
Name    REG_SZ    Playlists
Name    REG_SZ    PrintersFolder
Name    REG_SZ    PrintHood
Name    REG_SZ    Profile
Name    REG_SZ    ProgramFiles
Name    REG_SZ    ProgramFilesCommon
Name    REG_SZ    ProgramFilesCommonX64
Name    REG_SZ    ProgramFilesCommonX86
Name    REG_SZ    ProgramFilesX64
Name    REG_SZ    ProgramFilesX86
Name    REG_SZ    Programs
Name    REG_SZ    Public
Name    REG_SZ    PublicAccountPictures
Name    REG_SZ    PublicGameTasks
Name    REG_SZ    PublicLibraries
Name    REG_SZ    Quick Launch
Name    REG_SZ    Recent
Name    REG_SZ    Recorded Calls
Name    REG_SZ    RecordedTVLibrary
Name    REG_SZ    RecycleBinFolder
Name    REG_SZ    ResourceDir
Name    REG_SZ    Retail Demo
Name    REG_SZ    Ringtones
Name    REG_SZ    Roamed Tile Images
Name    REG_SZ    Roaming Tiles
Name    REG_SZ    SavedGames
Name    REG_SZ    SavedPictures
Name    REG_SZ    SavedPicturesLibrary
Name    REG_SZ    Screenshots
Name    REG_SZ    Searches
Name    REG_SZ    SearchHistoryFolder
Name    REG_SZ    SearchHomeFolder
Name    REG_SZ    SearchTemplatesFolder
Name    REG_SZ    SendTo
Name    REG_SZ    Start Menu
Name    REG_SZ    StartMenuAllPrograms
Name    REG_SZ    Startup
Name    REG_SZ    SyncCenterFolder
Name    REG_SZ    SyncResultsFolder
Name    REG_SZ    SyncSetupFolder
Name    REG_SZ    System
Name    REG_SZ    SystemCertificates
Name    REG_SZ    SystemX86
Name    REG_SZ    Templates
Name    REG_SZ    ThisDeviceFolder
Name    REG_SZ    ThisPCDesktopFolder
Name    REG_SZ    User Pinned
Name    REG_SZ    UserProfiles
Name    REG_SZ    UserProgramFiles
Name    REG_SZ    UserProgramFilesCommon
Name    REG_SZ    UsersFilesFolder
Name    REG_SZ    UsersLibrariesFolder
Name    REG_SZ    VideosLibrary
Name    REG_SZ    Windows
Sign up to request clarification or add additional context in comments.

2 Comments

I got an error running your code in a powershell file (simply copy-pasted). BUT this is a really interesting answer as well! It grabs more url schemes than just the one required to launch the app, but those other one seem useful. I'm going to write up a script based off of the first answer and update my answer too.
It's a windows batch file (.bat) not PS1.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.