如何通过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应用程序 file来获取启动应用程序的特定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天气应用程序有:
<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应用程序的每个.exe文件的路径,以便稍后我可以创建一个Windows列表,以显示给应用程序中的用户。然后,用户可以单击该应用程序,并打开与其相关的.exe文件。
发布于 2019-05-13 01:40:37
它们都列在HKCR下。
例如
HKEY_CLASSES_ROOT\bingweather显示URL:bingweather
计算器也是一样。尽管Calc.exe在System32中启动计算器。
因此,这些必须通过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例如
(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也可以打开文件夹,这个打开的临时互联网文件。
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 Windowshttps://stackoverflow.com/questions/56104703
复制相似问题