如何防止用户在安装软件时登录电脑?

如何防止用户在安装软件时登录电脑?

因此,我目前正在寻找一种解决方案,让用户在软件安装或激活无法移动、关闭且始终位于顶部的弹出消息时保持注销状态,因为有时当我们向用户部署软件(通过 SCCM)时,安装参数要求用户在安装期间处于注销状态。我尝试自定义组策略以锁定帐户,但没有成功。有人知道有什么程序或脚本可以做到这一点吗?

谢谢你!

答案1

我只是想让看到这个问题的人知道我用另一种方法解决了我的问题。基本上,我最终使用了 PSTools 和 AutoIt3 脚本。

我首先在 powershell 中编写了一个脚本,在登录屏幕上显示 HTA 启动画面,通知用户正在进行安装,如下所示:

#Set-ExecutionPolicy -ExecutionPolicy Bypass -Force
#$ErrorActionPreference = 0
$args = @('-accepteula', '-s', '-h', '-x', 'mshta.exe "c:\temp\splash.hta"')
$thisfolder = Split-Path -Parent $MyInvocation.MyCommand.Definition #Get's the folder you are currently in
$installpath = "C:\GOOGLE_SKETCHUP_PRO_14p0p4900\Install-Sketchup2014.cmd" #path to install (msi, exe, cmd, etc...)

Copy-Item $thisfolder\* C:\temp -Exclude *.ps1 -Recurse -Force
start-process -file c:\temp\pstools\psexec.exe  -ArgumentList $args -WindowStyle Minimized #opens login splash screen
#Start-process $installpath -NoNewWindow -Wait -WindowStyle Hidden #starts the install and waits until its finished to close the splash screen
Start-Sleep 10 #To simulate an installation.. 
Get-Process mshta | Stop-Process -Force #closes the splash screen
Get-Process PSEXESVC | Stop-Process -Force #closes the PSExec
cmd.exe /c "rd C:\TEMP\PSTools /s /q" #removes pstools from computer
cmd.exe /c "del C:\TEMP\splash.hta /q /f" #removes splash screen files from computer

然后我使用 autoIt3 脚本通过 AutoIt3 的 BlockInput() 函数在安装期间锁定鼠标和键盘。我将脚本转换为 EXE,这样它就可以在机器上未安装 autoit 的情况下运行。

希望这能帮助其他正在寻找阻止用户登录解决方案的人。

答案2

您可以查看更改以下注册表值:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit

此值控制用户登录系统时发生的情况。默认情况下,它通常具有如下值:

C:\windows\system32\userinit.exe

但您可以根据需要更改它。例如,我们有一些系统,我们希望它们充当转储终端,连接到我们的 Citrix 终端服务器群。我们通过将此值更改为以下内容来实现此目的:

c:\\windows\\system32\\wscript.exe c:\\someFolder\\somescript.vbs

这不会阻止用户登录系统,而是阻止用户登录后启动其环境。您可以执行类似操作,其中脚本会重命名当前用户初始化价值类似于Original_Userinit然后创建一个新的,指向一个脚本,一旦用户重新登录,该脚本就会将其注销。然后,一旦你完成了你正在做的事情,你就把这个值重命名为其他名称,例如注销用户初始化,然后将原来的名称重命名回来。

再次,这不会阻止用户登录,但会阻止启动登录会话并立即将其注销。

相关内容