情况/上下文/意图
我尝试运行一个任务(在windows 10上),根据NetConnection名称(查看我是否在家)激活或停用自动登录。脚本工作并被执行,但我认为任务太晚了,因为自动登录使用的是脚本设置的预先存在的值。或者,是因为Wi延迟了脚本,Wi可能还在启动,允许自动登录来做它的事情或者诸如此类的事情?
我试过什么
首先,我在互联网上看到,但我所能找到的只是如何激活自动登录,而不是任何接近我试图做的事情。
然后,在堆栈溢出上,我确实发现了一个叫做gina.dll的东西。结果表明,它已经被凭据提供程序替换。这看起来像一个前卫最好避免,我认为,它只是接口登录无论如何。
然后我尝试使用这个事件,内核启动id 30,它应该监视启动过程。“也许这会比默认的启动早一些,”我想。但是,我观察到的结果与“启动时”的结果相同。(也许这和“创业”是一样的。)
脚本(PowerShell)
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
if((Get-NetConnectionProfile | select -ExpandProperty Name) -ceq "The connection name"){
Set-ItemProperty $RegPath "AutoAdminLogon" -Value "1" -type String
}else{
Set-ItemProperty $RegPath "AutoAdminLogon" -Value "0" -type String
}导出的任务
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2022-01-02T17:37:14.7356723</Date>
<Author>LAPTOP\admin</Author>
<Description>Connexion automatique à admin</Description>
<URI>\Tâche personalisé\Connexion automatique</URI>
</RegistrationInfo>
<Triggers>
<BootTrigger>
<Enabled>true</Enabled>
</BootTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>I probably do not want that out there</UserId>
<LogonType>Password</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT1M</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>PowerShell</Command>
<Arguments>C:\ScriptPersonnalise\ConnexionAutomatique.ps1</Arguments>
</Exec>
</Actions>
</Task>发布于 2022-01-04 11:08:44
对不起,大卫,我错了,我不明白你的意思。你的分析完全正确。
但是你不能通过使用预定的任务来做你想做的事情。即使在启动时进行配置,计划的任务/脚本也将在系统处理AutoAdminLogon之后执行。
为了在系统到达之前执行脚本,您需要使用组策略。有两件事要做:
通过运行gpedit.msc启动组策略控制台
(Startup/Shutdown)

启用启动脚本的同步处理

等等!
考虑使用来自SysInternals的一个名为AutoLogon的工具,该工具可以帮助您以稍微安全的方式实现目标,因为允许您使用加密的密码。
发布于 2022-01-04 16:46:43
只要您定义了Windows 10的环境和普通tex用户名/密码的知识,您就可以实现您自己的Credential Provider。
您的提供者将被调用为ICredentialProvider::SetUsageScenario和ICredentialProvider::GetCredentialCount。
这一次,你可以做一个决定,做自白或不。
作为评估的结果,您可以在TRUE参数处返回pbAutoLogonWithDefault。
稍后,您的提供程序将被调用为ICredentialProviderCredential::GetSerialization,在这里您可以序列化用户名和密码。
https://stackoverflow.com/questions/70571343
复制相似问题