以编程方式解锁 Windows 工作站

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/174225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:29:29  来源:igfitidea点击:

Unlock Windows workstation programmatically

windowssecuritywinapi

提问by Dan Cristoloveanu

I would like to write a small application that unlocks the workstation. To put the specs of what I need very simple: Have an exe that runs and at a defined time (let's say midnight) unlocks the workstation. Of course the application knows the user and password of the logged on account.

我想编写一个解锁工作站的小应用程序。把我需要的规格说得很简单:让一个 exe 运行并在定义的时间(假设是午夜)解锁工作站。当然,应用程序知道登录帐户的用户名和密码。

I know of the LogonUser API and have tried using it but failed. Does anyone have a solution, code excerpt that actually works for this issue?

我知道 LogonUser API 并尝试使用它但失败了。有没有人有解决方案,代码摘录实际上适用于这个问题?

I am targeting NT5 OSes.

我的目标是 NT5 操作系统。



Well, since people started asking what is the reason: I am working on a desktop sharing application and I want to add the feature of unlocking the workstation. Having the very small and simple app to unlock the station at a defined time is in order to separate the problem and to avoid the integration details.

好吧,既然人们开始问原因是什么:我正在开发一个桌面共享应用程序,我想添加解锁工作站的功能。使用非常小而简单的应用程序在规定的时间解锁电台是为了分离问题并避免集成细节。

回答by Henry B

Just so you have an answer for this instead of people leaving answers which might be better off as comments.

只是为了让您对此有一个答案,而不是人们留下答案作为评论可能会更好。

This is certainly possible, though as many people have already said it's not really wise, what happens if someone is walking by the computer as it unlocks, how long do they have to play around, etc?

这当然是可能的,尽管很多人已经说过这不是很明智,如果有人在电脑解锁时走过会发生什么,他们需要玩多久,等等?

Anway, apart from suggesting you have a service to do any work that you want on hte computer, or even remotely connecting to the computer to do work you might be able to make user of the following information. (as for 'code excerts' you can make it yourself)

Anway,除了建议您有一项服务可以在计算机上完成您想要的任何工作,甚至远程连接到计算机进行工作之外,您还可以让用户了解以下信息。(至于“代码 excerts”,您可以自己制作)

http://www.paralint.com/projects/aucun/is a GINA implementation which will be able to give you rights to log on even if someone else has already logged on. Look into it it might be what you're looking for and is a lot safer than unlocking the workstation at a certain time.

http://www.paralint.com/projects/aucun/是一个 GINA 实现,即使其他人已经登录,它也可以授予您登录的权限。调查一下,它可能就是您要找的东西,而且比在特定时间解锁工作站要安全得多。

As an alternative, look into writing your own GINA implementation that will do an unlock at a scheduled time.

作为替代方案,考虑编写您自己的 GINA 实现,该实现将在预定时间进行解锁。

Information on GINA

GINA信息

http://msdn.microsoft.com/en-gb/magazine/cc163803.aspx

http://msdn.microsoft.com/en-gb/magazine/cc163803.aspx

http://msdn.microsoft.com/en-us/magazine/cc163786.aspx

http://msdn.microsoft.com/en-us/magazine/cc163786.aspx

After you've unlocked the desktop I'm pretty sure you're going to want to lock it again.

在您解锁桌面后,我很确定您会想要再次锁定它。

http://www.codeproject.com/win32/AntonioWinLock.asp

http://www.codeproject.com/win32/AntonioWinLock.asp

回答by VonC

Just to add another lead (an not have any judgment), autoit(a scripting Windows language) may have an answer, as described in this thread:

只是添加另一个线索(没有任何判断),autoit(一种脚本 Windows 语言)可能有一个答案,如该线程中所述:

How to unlock an Xp desktop

如何解锁 Xp 桌面

And I just found another scenario where one might want to unlock a desktop;)

我刚刚发现了另一种可能想要解锁桌面的场景;)

回答by zomf

For my situation I needed to be able to restore the console session after I've disconnected my terminal session (I'm connecting to a WinXPe kiosk with a touchscreen, but no keyboard).

对于我的情况,我需要能够在断开终端会话后恢复控制台会话(我正在连接到带有触摸屏但没有键盘的 WinXPe 信息亭)。

Here's a command line solution I found to work. Instead of closing my session window to disconnect, I run a batch file with the following line. My session is closed and the console session is restored unlocked.

这是我发现有效的命令行解决方案。我没有关闭会话窗口以断开连接,而是使用以下行运行批处理文件。我的会话已关闭,控制台会话已恢复解锁。

  • automatically unlock workstation after terminal session on WinXP

    tscon.exe 0 /dest:console
    
  • for Windows Vista/7 the console session number has changed from 0 to 1, so you need to use

    tscon.exe 1 /dest:console
    
  • 在 WinXP 上终端会话后自动解锁工作站

    tscon.exe 0 /dest:console
    
  • 对于 Windows Vista/7,控制台会话编号已从 0 更改为 1,因此您需要使用

    tscon.exe 1 /dest:console
    



Source link: http://arstechnica.com/civis/viewtopic.php?f=15&t=69113



来源链接:http: //arstechnica.com/civis/viewtopic.php?f=15&t=69113

回答by Johan Bresler

Let your app run as a service, then you do not need user/password as that is set up with the service.

让您的应用程序作为服务运行,然后您不需要用户/密码,因为它是与服务一起设置的。