如何在C:\Program Files\WindowsApps\some_app_folder\*.exe
内通过powershell打开可执行文件?
当我运行以下powershell命令时:
Start-Process -FilePath '.\Calculator.exe'
#full path example: C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1903.21.0_x64__8wekyb3d8bbwe\Calculator.exe
我收到此错误:“ 由于错误而无法运行此命令:访问被拒绝”
观察:
Calculator
,然后按Enter,则可以通过Windows搜索以这种方式打开应用程序。 是否可以以其他可以打开此文件的用户身份运行该过程?
手动解决方法:
通过查看每个Windows应用程序C:\Program Files\WindowsApps\some_app\AppxManifest.xml
file,我可以从每个Windows应用程序中获取启动该应用程序的特定URI快捷方式。例如,我可以通过这种方式启动一些Windows应用程序:
# Powershell ...you can also run this inside "Run as" without `Start-Process
Start-Process calculator:
Start-Process ms-photos:
Start-Process Spotify:
但是我试图避免这种情况,只使用.exe
文件即可。抓紧每个清单不能很好地完成工作,因为AppxManifest
可以定义几个甚至最多十二个URI快捷方式来启动应用程序(某些快捷方式进入应用程序的不同页面)。例如,Windows Weather应用具有:
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="msnweather"/>
</uap:Extension>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="bingweather"/>
</uap:Extension>
我需要在脚本中手动创建要保留或排除哪些URI快捷方式的黑名单。
目标:
.exe
文件
Windows应用 -希望无需更改用户的注册表文件。
我正在为每个Windows应用程序收集每个.exe
文件的路径,因此以后可以创建Windows应用程序列表以显示给应用程序中的用户。然后,用户将能够单击该应用程序并打开其相关的.exe文件。
答案 0 :(得分:0)
它们都列在HKCR
下。
EG
HKEY_CLASSES_ROOT\bingweather
显示URL:bingweather
与计算器相同。尽管System32中的Calc.exe启动了计算器。
,因此必须通过shellexecute
运行。因此,如果在CMD中,则需要使用Start
命令。
start calculator://
start bingweather://
等
此命令将列出所有内容,但它还会获取其他一些键。
@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
您还可以打开文件夹,这将打开Temp Internet Files。
start shell:cache
要生成
@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
这是列表,如果空格有空格,请使用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