用于更改用户的注销脚本

发布于 2024-07-12 08:02:41 字数 435 浏览 10 评论 0原文

使用 Windows 2003,我正在寻找一种方法来创建“注销脚本”,该脚本将继续当前注销,然后立即登录另一个用户。 因此,“UserA”注销。 触发脚本以登录“UserB”。

这是我们编写“shell”的计算机应用程序升级的一部分; 类似于信息亭应用程序。 对于升级,我们需要以“管理员”身份登录,然后在升级完成后,注销“管理员”并以“sample_user”身份登录。 我们希望在不重新启动的情况下完成此操作。

请注意,我不需要启动注销(即“关闭”)的脚本。 我正在寻找一个将在用户登录时运行的 脚本关闭(通过组策略设置)。 如上所述,脚本应该让不同的用户登录。

谢谢。

Using Windows 2003, I'm look for a way to create a "logoff script" that will continue with the current logoff then immediately login another user. So, "UserA" logs off. Script fires to login "UserB".

This is part of an application upgrade for a computer where we have written the 'shell'; similar to a kiosk application. For the upgrade we need to logon as 'Adminstrator' then, when the upgrade has completed, logoff 'Administrator' and logon as 'sample_user'. We would like to accomplish this WITHOUT rebooting.

Note, I do not want a script that will initiate the logoff (i.e. "shutdown"). I'm looking for a script that will run upon the user logging off (set via Group Policies). As above, the script should log a different user on.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

南…巷孤猫 2024-07-19 08:02:41

不要认为以规定的方式(注销时的脚本)是可能的。

您必须将计算机设置为以指定帐户自动登录,然后注销(让它自动为您登录),然后您必须通过放置临时登录脚本再次禁用该功能...一般听起来很混乱。

实际设置可以使用 Microsoft 共享计算机工具包或类似工具进行(不太确定手动注销时“正常”注册表自动登录的行为方式,但我有一个 XP 信息亭,它会立即自动登录,即使您手动注销 - 您必须使用某些键(例如shift+logoff)覆盖它才能再次手动指定登录,因此可以以某种方式进行)。

“最简单”的方法可能是用您自己制作的东西替换 msgina.dll...

但是您为什么要这样做? 只需使用runas并以其他用户身份启动您需要执行的任何操作,而无需注销控制台用户 - 毕竟这是一个多用户系统? 桌面只是绒毛^^

这将要求用户凭据可用于您的脚本,这在您危及该帐户的安全性时使其变得多余 - 违背了在桌面中拥有第二个帐户的目的第一名,无论它存在的目的是什么?

Don't think it's possible in the stated way (script at logoff).

You'd have to set the machine to logon automatically as a specified account and then log off (having it log on automatically for you) and then you'd have to disable that feature again afterwards, by placing a temporary logon script... generally sounds messy.

The actual setting can be made using tools like Microsofts Shared Computer Toolkit or similar (not so sure how the "normal" registry auto-login behaves at manual logout but I've had an XP kiosk that would automatically log on instantly, even if you logged out manually - you had to override it using some key like shift+logoff to be able to manually specify the login again, so somehow it can be made).

The "easiest" way might be to replace msgina.dll with someone of your own making...

But why are you doing this? Just use runas and start whatever you need to do as that other user without logging off the console user - it's a multi-user system afterall? The desktop is just fluff ^^

(This will anyhow require that the user credentials are available to your script, which kind of makes it redundant as you compromise the security of that account - defying the purpose of having that second account in the first place, for whatever purpose it exists?)

温柔少女心 2024-07-19 08:02:41

我会尝试使用您想要的用户将注册表设置为自动登录,然后只需注销管理员用户。 这应该可以让您的信息亭用户重新登录。

I would try setting the registry to autologon with the user you want, and then simply logging off the admin user. That should log your kiosk-user right back on.

吾家有女初长成 2024-07-19 08:02:41

不确定当前用户注销后如何登录另一个用户(不确定 Windows 是否允许您...)

但是您可以使用 shutdown 来注销:

关闭/? 
  

Not sure how to login another user once the current user logs off (not sure if windows would let you...)

But you can use shutdown to logoff:

shutdown /?
只怪假的太真实 2024-07-19 08:02:41

以下是一些可能属于“廉价黑客”类别的想法:

首先登录 UserB,然后使用 runas /user:userA 运行第一部分安装过程?

如果这是不可接受的,我知道有一种方法可以使 Windows 工作站(不属于域的工作站)在重新启动后自动登录到某个用户帐户。 也许如果您查看发生了哪些注册表更改并复制它们,重新启动将自动登录该用户。 (当然,作为最后阶段,在 userB 登录后,您必须恢复这些更改:-)

我还想知道是否有一种方法可以让服务强制打开“登录屏幕”进行登录作为某个用户。 也许使用某种方法,例如远程桌面远程执行的方式...如果可能的话,那么您可以创建一个在用户 A 注销之前安装的服务,这将触发用户 B 的登录。

Here's some ideas that probaly fall into the "cheap hack" category:

How about logging in at UserB in the first place, and then using runas /user:userA <cmd> to run the first part of the install process?

If that's unacceptable, I know there's a way to make Windows workstations (those that aren't part of a Domain) automatically log in into a certain user account after a restart. Perhaps if you looked into which Registry changes happen, and duplicated them, a reboot would automatically log in that user. (Of course, as a final stage, after userB logs in, you would have to revert those changes :-)

It also occurs to me to wonder if perhaps there's a way for a service to force an open "login screen" to log in as a certain user. Maybe using some method like the way the Remote Desktop does it remotely... If that's possible, then you could create a service that you install before logoff of userA, that would trigger the login of userB.

翻了热茶 2024-07-19 08:02:41

您可以使用 VNC 编写脚本(有很多免费版本,您可以选择)。 在计算机上设置 VNC 服务器进程以侦听本地主机。 当用户注销时,您的注销脚本将使用 VNC 连接到计算机并发送登录下一个用户所需的击键。 VNC使用RFB(远程帧缓冲)协议; 有针对大多数流行语言的库,因此您应该能够快速运行某些东西。 或者有相关的工具可能有帮助。

You can script it with VNC (there are many free versions, take your pick). Set up a VNC server process on the machine to listen on localhost. When the user logs off, your logoff script will connect to the machine using VNC and send the keystrokes necessary to log on the next user. VNC uses the RFB (remote framebuffer) protocol; there are libraries for most popular languages, so you should be able to get something working quickly. Or there are related tools that might help.

以酷 2024-07-19 08:02:41

如果您要以给定语言将类似的内容作为普通脚本运行,那么它很可能无法工作,因为当您注销帐户时,所有进程都应该与正在运行的脚本一起被终止。

您也许能够创建某种在服务帐户(即始终处于活动状态)上运行的“服务”,该服务帐户会自动为您执行此用户切换。

我押注于 Windows Powershell,尽管我并不完全确定它在实际创建服务方面具有哪些功能。

快速搜索会显示以下内容(第二个链接是论坛,但它提到将 Powershell 作为服务运行并向该服务发送一个参数,该参数将是用户切换脚本的路径)

如何使用 Powershel 创建 Windows 服务

Powershell 脚本作为 Windows 服务

If you were to run something like this as a normal script in a given language, it would most likely not work as when you log out of your account, all processes should be killed along with your running script.

You might be able to create some sort of 'service' that would run on a service account (i.e. always active) that would automatically do this user switching for you.

My bets are on Windows Powershell, although I'm not entirely sure what functionality it has as far as actually creating a service.

A quick search brings up the following (The second link is to a forum but it mentions running Powershell as a service and sending that service a parameter which would be the path to your user switching script)

How to Create a Windows Service using Powershel

Powershell Script as a Windows Service

早茶月光 2024-07-19 08:02:41

我没有 Windows 2003 服务器或具有“组策略”设置的系统来测试我的预感,但您可以查看适用于 Windows 的 SU(“切换用户”)。 最初是资源工具包的一部分,现已扩展到新的 SUperior SU。 如果有效,请发布结果/脚本。

I don't have a Windows 2003 server or a system with a "Group Policies" setup to test my hunch but you could take a look at SU ("switch user") for Windows. Originally part of the Resource Toolkit this has been extended to a new SUperior SU. Do post the results/script if this works.

趁年轻赶紧闹 2024-07-19 08:02:41

您可以从构建远程控制实用程序(如 VNC 等)的角度来解决这个问题。 这里最重要的是,如果您想访问登录屏幕(即 CTRL + ALT + DEL / 用户名/密码)部分,唯一的问题是 Windows 服务是唯一可以访问此部分的组件,因此您需要必须创建一个。

我认为这个技术作为一个整体的唯一问题是,即使你花费了大量的努力让它工作(这将是一个相当大的努力),这个工作成功的机会来自于整个事情即使由于以管理员身份重新登录时可能出错的事情很多,注销脚本(即当东西关闭时)也很低。

请记住,对于需要以管理员身份运行的任何内容,Windows 中有更简单的方法来实现这一点(例如运行方式、更改需要更新的项目的用户权限等)。

You could approach this from the perspective of building a remote control utility (like VNC, etc). The big thing here is that if you want access to the Logon screen (i.e. the CTRL + ALT + DEL / username/password) part, the only kicker is that a Windows Service is the only component that can access this, so you'd have to create one.

The only problem I see with this technique as a whole is that even if you spent a great deal of effort getting it to work (and it would be a pretty big effort), the chances of this working successfully with the whole thing originating from a logoff script (i.e. when stuff is shutting down) are low even due to the number of things that can go wrong when logging back on as Administrator.

Just remember that for anything you need to run as an Administrator, there are easier ways in Windows to make that happen (such as Run As, changing the user permissions on the items that need to update, etc).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文