Windows 10 รองรับการรันแอปพลิเคชันในฐานะผู้ใช้อื่น (Run As Different User) ในเซสชันปัจจุบัน ซึ่งช่วยให้รันสคริป्ट (.bat, .cmd, .vbs, .ps1), ไฟล์ 실행 (.exe) หรือติดตั้งโปรแกรม (.msi, .cab) ด้วยสิทธิ์ผู้ใช้อื่น (มักเป็น Admin) ได้
รันจาก File Explorer (GUI)
- หาไฟล์หรือ Shortcut ที่ต้องการรัน
- กดปุ่ม Shift ค้าง + คลิกขวา
- เลือก Run as different user
- กรอก Username และ Password (รูปแบบ Domain:
Domain\UserหรือUser@Domain) - กด OK — โปรแกรมจะรันภายใต้บัญชีนั้น
หมายเหตุ: หากไม่見 "Run as different user" ให้ตรวจสอบ Group Policy: gpedit.msc > Computer Configuration > Administrative Templates > Windows Components > Credential User Interface > Require trusted path for credential entry = Disabled/Not Configured
ใช้คำสั่ง RunAs.exe จาก Command Prompt
runas /user:admin "C:\Windows\notepad.exe"
runas /user:"antony jr" notepad.exe
runas /user:corp\server_admin "notepad.exe C:\ps\region.txt"
runas /netonly /user:contoso\bmorgan cmd.exe
พารามิเตอร์สำคัญ:
- /noprofile – ไม่โหลด User Profile (เร็วขึ้น แต่อาจทำให้บางโปรแกรมทำงานผิด)
- /savecred – บันทึกรหัสผ่านใน Credential Manager (ไม่แนะนำให้ใช้กับบัญชี Admin เนื่องจากความปลอดภัย)
สร้าง Shortcut สำหรับ Run As Different User
- คลิกขวา Desktop > New > Shortcut
- พิมพ์คำสั่ง:
runas /user:admin /savecred "C:\Windows\cmd.exe" - ตั้งชื่อ Shortcut
- ครั้งแรกจะถามรหัสผ่าน ครั้งต่อไปจะใช้ Credential ที่บันทึกไว้
รัน MMC Snap-ins เป็นผู้ใช้อื่น
runas.exe /user:DOMAIN\USER "cmd /c start \"\" mmc %SystemRoot%\system32\dsa.msc"
เปลี่ยน dsa.msc เป็น snap-in อื่นๆ เช่น compmgmt.msc, gpmc.msc เป็นต้น
เพิ่มเมนู "Run as different user" ใน Start Menu
- เปิด
gpedit.msc - ไป User Configuration > Administrative Templates > Start Menu and Taskbar
- Enable Show Run as different user command on Start
- หรือเพิ่ม Registry:
HKCU\Software\Policies\Microsoft\Windows\Explorer\ShowRunasDifferentuserinStart= 1 (DWORD) - รัน
gpupdate /force
ข้อกำหนดเบื้องต้น
- บริการ Secondary Logon (seclogon) ต้องทำงานอยู่ (
Get-Service seclogon) - บัญชีเป้าหมายต้องมีรหัสผ่าน (Empty password ไม่ทำงาน)