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

แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้

หลังติดไวรัส หรือแก้ Registry ผิดพลาด ผู้ใช้อาจเจอปัญหา ไฟล์ EXE (รวม MSI, PowerShell/CMD/VBScript) เปิดไม่ได้ใน Windows เมื่อรันโปรแกรม (Shortcut) จาก File Explorer ไม่เกิดอะไรขึ้น หน้าต่างถามเลือกโปรแกรมปรากฏ หรือ EXE ทั้งหมดเปิดในโปรแกรมอื่น (เช่น Notepad, Paint) บทความนี้จะแนะนำวิธีแก้ปัญหาเมื่อไม่สามารถรันไฟล์ Executable หรือ Application ใดๆ บน Windows ได้

วิธีแก้ไข File Association ของ EXE ที่เสียหายบน Windows

เมื่อรันไฟล์ *.exe ใดๆ ใน Windows จะมีหน้าต่างถามเลือกโปรแกรม (How do you want to open this file?):

แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้

หรือ Error ขึ้น:

This file does not have an app associated with it for performing this action. Please install an app, if one is already installed, create an association in the Defaults Apps Settings page.
Windows cannot access the specified device, path, or file. You may have the appropriate permissions to access the item.
Windows can't open this file.

แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้

ปัญหานี้มักเกิดหลังติดไวรัส หรือพยายาม "Optimize" Registry ไม่สำเร็จ ต้นเหตุคือ File Association สำหรับ *.exe ถูกรีเซ็ตใน Registry ต้องใช้ Registry Editor (regedit.exe) แก้ไข แต่ regedit.exe ก็เป็น EXE เหมือนกัน ไม่เปิดได้ cmd.exe และ PowerShell ก็เปิดไม่ได้ ต้องทำอย่างไร?

  1. สร้าง Text File ธรรมดาบน Desktop;
  2. วางบรรทัดนี้: start cmd
  3. เปลี่ยนชื่อไฟล์เป็น run.bat;
  4. คลิกขวาไฟล์ เลือก Run as administrator; แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้
  5. ยืนยัน UAC Elevated Command Prompt จะเปิด;
  6. รัน regedit.exe แก้ Registry เอง (วิธีด้านล่าง) หรือวางโค้ดนี้ใน CMD:
    reg delete HKEY_CLASSES_ROOT\.exe /ve /f
    reg add HKEY_CLASSES_ROOT\.exe /ve /d exefile /f
    reg delete HKEY_CLASSES_ROOT\exefile /ve /f
    reg add HKEY_CLASSES_ROOT\exefile /ve /d Application /f
    reg delete HKEY_CLASSES_ROOT\exefile\shell\open\command /ve /f
    reg add HKEY_CLASSES_ROOT\exefile\shell\open\command /f /ve /d "\"%1\" %*\"
    assoc .exe=exefile

    แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้
  7. คำสั่งเหล่านี้จะ Reset EXE File Associations กลับเป็น Default;
  8. Restart เครื่อง และลองรัน App ใดๆ

หาก *.bat และ *.cmd ก็รันไม่ได้ ต้องแก้ Registry Manual ใน Safe Mode

  1. บูทเข้า Safe Mode (กด Power Button 3 ครั้งติดกันตอนบูทเพื่อ Interrupt);
  2. เข้าสู่ Windows Recovery Environment (WinRE) เลือก Troubleshoot -> Advanced options -> Startup Settings -> Restart กด F4 เข้า Safe Mode;
  3. รัน Registry Editor (regedit.exe) ไปที่คีย์ HKEY_CLASSES_ROOT\.exe;
  4. เปลี่ยนค่า Default ให้เป็น exefile; แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้
  5. ไปที่ HKEY_CLASSES_ROOT\exefile\shell\open\command เปลี่ยนค่า Default เป็น "%1" %* แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้
  6. ทำเช่นเดียวกับ HKCR\exefile\shell\open และ HKCR\exefile ให้ค่า Default เป็น "%1" %*;
  7. Restart ปกติ File Explorer ควรใช้ Default EXE Associations ลองรัน *.exe ใดๆ

เพิ่มเติม ขั้นตอนตรวจสอบ/แก้ไข EXE Associations:

  • รันคำสั่ง Reset: assoc .exe=exefile
  • ตรวจสอบว่า Key UserChoice ไม่มีใน HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.exe หากมี ให้ลบ;
  • ตรวจสอบ Integrity ของ Windows Image และ System Files:
    sfc /scannow
    DISM /Online /Cleanup-Image /RestoreHealth
  • ตรวจสอบว่า Antivirus ไม่ได้บล็อกการรัน Executable Files;
  • หาก Windows แจ้งเตือน Security Warning ตอนเปิด EXE ให้ทำตามบทความนี้

Windows ไม่สามารถรัน EXE Files จาก Network Share ได้

หาก User รัน EXE Locally ได้ แต่ Error ตอนรันจาก Network Shared Folder สาเหตุอาจต่างออกไป

  1. ตรวจสอบ NTFS Permissions ของ Shared Folder/File หาก User ไม่มี NTFS Read/Execute จะ Error:
    Windows cannot access \\server1\sharedfolder\file.exe. You do not have permission to access applicatin.exe file.
    แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้
  2. ลองรัน EXE ใน Compatibility Mode: Properties -> Compatibility Tab -> เลือก Windows 8 ลองรันจาก Network Share

แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้

อาจเกี่ยวกับการเชื่อมต่อ Shared Folder บนอุปกรณ์ที่รองรับแค่ SMB v1 (NAS, File Server Legacy OS เช่น Windows XP/Server 2003)

Error ที่บ่งชี้:

The application was unable to start correctly (0xc00000ba)
Exception thrown at 0x00007FFA2B86624E
0xC0000005: Access violation reading location 0x0000000000000000)

Note Client และ Server ต่อกันผ่าน SMB จะเลือก Protocol Version สูงสุดที่รองรับพร้อมกัน (ดู SMB versions in Windows) ตรวจสอบ SMB Version ที่ Client ใช้เชื่อมต่อด้วย Get-SmbConnection

แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้

ตรวจสอบ SMBv2/v3 บน File Server: Get-SmbServerConfiguration | Select EnableSMB2Protocol

หาก SMBv2 Disabled ให้ Enable: Set-SmbServerConfiguration -EnableSMB2Protocol $true

หากใช้ Linux Samba ให้ Disable SMB1 ใน smb.conf: เพิ่ม min protocol = SMB2 ใน Section [global] Restart Samba

Default: ไม่สามารถ Access SMB Share บน Server 2003 หรือ NAS ที่รองรับแค่ SMB1 จาก Windows 10 Build ใหม่ ต้อง Enable SMB 1.0/CIFS Client บน Client (ไม่แนะนำเพราะ Security)

แก้ไข: ไม่สามารถเปิดไฟล์ Executable (.EXE) บน Windows ได้

วิธีแก้ที่ถูกต้อง: Migrate Shares ไป Windows Server 2012 R2/2016/2019 ที่ Disable SMB1 แล้ว จึงจะรัน EXE จาก Shared Folder บน Windows 10 ได้