Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows

แก้ไข PowerShell Get-Appxpackage Access Denied, Not recognized หรือ Not working

Get-Appxpackage เป็น PowerShell command ที่แสดงรายการ app packages ที่ติดตั้งใน user profile รวมถึง apps จาก Microsoft Store และ third-party apps ตอนใช้คำสั่ง หากเจอ error — Powershell Get-Appxpackage Access Denied, Not Recognized or Not Working โพสต์นี้จะช่วยแก้

แก้ไข PowerShell Get-Appxpackage Access Denied, Not recognized หรือ Not working

Error message อาจแตกต่างไป แต่โดยปกติจะอ่านว่า:

Get-AppxPackage : The service cannot be started, either because it is disabled or because it has no enabled devices
associated with it. The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.

PowerShell Get-Appxpackage Not working

เป็น permission issue แก้ได้ด้วยการเช็คบางอย่าง

  1. Run PowerShell With Admin Permission
  2. Check Permission With Destination Directory
  3. Check AppX Deployment Service status

ตอนเปลี่ยน permission โฟลเดอร์ ต้องแน่ใจว่าไม่ remove user account ที่มีอยู่แล้ว

1] Run PowerShell With Admin Permission

เนื่องจากคำสั่งต้องติดตั้ง application ระดับระบบ สำคัญที่ต้อง execute command เมื่อ launch ด้วย admin permission

  • กด Start button พิมพ์ PowerShell
  • ปรากฏในรายการ คลิกขวา เลือก Run as Administrator
  • Execute command ควรทำงานโดยไม่มี error

นอกจาก permission denied อาจได้ Not Recognized หรือ Not Working เป็น error Not Recognized เกี่ยวกับ admin permission Not working เกี่ยวกับ Services

ไป Services Snap-in หา Client License Service (ClipSVC) และ AppX Deployment Service (AppXSVC) ตรวจสอบว่า available และ running

2] Check Permission With Destination Directory

หากติดตั้ง application ในโฟลเดอร์เฉพาะ ให้แน่ใจว่ามี full permission เขียนไฟล์ภายใน

  • ไป Destination folder คลิกขวา Properties
  • สลับไป Security tab
  • เช็คว่า account ของคุณมีอยู่ และมี full permission
  • เช็คว่า System user account มีอยู่และมี full control
  • หาไม่มี กด Edit button เพิ่มพร้อม permission

3] Check AppX Deployment Service status

ใน PowerShell console รัน Get-Service "AppXSvc" ดู

AppX Deployment Service (AppXSVC) Status ควรเป็น Running

หาเป็น Stopped เปิด command prompt as administrator รัน:

net start AppXSvc

ทางเลือก: เปิด Regedit ไปที่:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\AppXSvc

ตั้งค่า "Start" เป็น "3" และ reboot

หลังเปลี่ยนแปลง Execute command error ควรไม่เกิดแล้ว

อ่านเพิ่ม: วิธีเปลี่ยน File และ Folder permissions ใน Windows

How Do I Enable AppxPackage?

คำสั่งและไฟล์เกี่ยวข้องมีอยู่กับ Windows แล้ว ไม่ต้องติดตั้งอะไรพิเศษ แต่ต้อง execute ด้วย admin permission ไม่งั้นจะบอกว่า command not recognized

How to Restore Built-In Apps on Windows?

เปิด PowerShell with admin rights รันคำสั่งต่อไปนี้เพื่อ restore built-in apps ทั้งหมดใน Windows

Get-AppxPackage -AllUsers | For each app: Add-AppxPackage -DisableDevelopmentMode -Register "$($_InstallLocation)\AppXManifest.xml

จะใช้เวลาสักพัก และ apps ทั้งหมดที่มีตอน setup Windows ครั้งแรกจะกลับมา

หวังว่าโพสต์นี้เข้าใจง่าย และคุณเข้าใจสาเหตุ error ชัดเจน

แก้ไข PowerShell Get-Appxpackage Access Denied, Not recognized หรือ Not working