我有控制台应用程序在分配的访问权限(Windows 10 的 Kiosk 模式)下在后台运行。通过主 UWP 应用程序的命令,它应该注销当前用户。我尝试了两种方法来做到这一点:
- WinAPI函数
ExitWindowsEx(0, 0)
Process.Start("shutdown/l/f")
如果当前用户有密码,两者都可以正常工作。但如果用户没有密码,Windows 注销后会立即重新登录。有没有办法避免重新登录?
更新:
看起来 LockWorkStation
也不起作用。可能是出于安全原因?
最佳答案
根据Raymond Chen from Microsoft这是不可能的:
UWP applications cannot sign users out or lock the workstation. That would result in a denial of service from an app that just locked the workstation in a tight loop.
在您的客户端/服务器中,UWP 应用程序向桌面应用程序发送请求,方法尝试 WTSDisconnectSession()在桌面应用程序中调用,如 suggested here .
关于uwp - Windows 10 分配的访问权限 : how to logout programmatically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47815358/