Ein Skript zum Aktivieren der automatischen Anmeldung für Benutzer in einer Domäne funktioniert erst dann, wenn ich es zweimal ausführte

709
Youssef Karami

Ich habe also ein Problem mit einem Skript, das die automatische Anmeldung von Domänenbenutzern ermöglicht. Aus irgendeinem Grund muss ich es zweimal ausführen, damit die Option auf dem Computer aktiviert wird.

Das Skript:

@echo off REM Set variables set /p user-name= What is the username? set /p domain= What is the domain name? set /p password= What is the password?  REM Enable Auto Logon reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1  REM Set Username for logon reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d %user-name%  REM Set Domain reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d %domain%  REM Set Password reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d %password% 

Ich habe versucht, dieses Programm vom Technet zu verwenden, und ich hatte das gleiche Problem damit.

Ich würde mich sehr über Ihre Hilfe freuen!

0
ähnlich: http://superuser.com/questions/487395/why-do-i-need-to-set-up-autologon-values-in-registry-tice-in-vor-der-mit-arbeitsan befzz vor 8 Jahren 0

2 Antworten auf die Frage

0
Youssef Karami

Ich habe mit diesem Skript zu PowerShell gewechselt:

$TheUser = Read-Host "What is the username?" $ThePassword = Read-Host "What is the password?" -AsSecureString $TheDomain = Read-Host "What is the domain?" New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon -Value 1 New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUserName -Value "$TheUser" New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -Value $ThePassword New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefautDomainName -value $TheDomain 

Bei jeder Ausführung des Skripts erhalte ich jedoch folgende Fehlermeldung:

New-ItemProperty: Die Eigenschaft ist bereits unter C: \ Users \ Administrator \ Desktop \ Autologon.ps1: 4 Zeichen: 17 + New-ItemProperty <<<< -Path 'HKLM: \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon vorhanden '-Name AutoAdminLogon -Value 1 + CategoryInfo: ResourceExists: (HKEY_LOCAL_MACH ... ersion \ Winlogon: String) [New-ItemProperty], IOException + FullyQualifiedErrorId: System.IO.IOException, Microsoft.PowerShell.Commands.NewItemPopOptPropOptup-. Die Eigenschaft ist bereits unter C: \ Users \ Administrator \ Desktop \ Autologon.ps1: 5 Zeichen: 17 + New-ItemProperty <<<< -Pfad 'HKLM: \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon' -Name DefaultUserName vorhanden -Value "$ TheUser" + CategoryInfo: ResourceExists: (HKEY_LOCAL_MACH ... ersion \ Winlogon: String) [New-ItemProperty],IOException + FullyQualifiedErrorId: System.IO.IOException, Microsoft.PowerShell.Commands.NewItemPropertyCommand New-ItemProperty: Die Eigenschaft ist bereits vorhanden unter C: \ Users \ Administrator \ Desktop \ Autologon.ps1: 6 Zeichen: 17 + New-ItemProperty <<< <-Path 'HKLM: \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon' -Name DefaultPassword -Value $ ThePassword + CategoryInfo: ResourceExists: (HKEY_LOCAL_MACH ... ersion \ Winlog bei: String) [New-ItemProperty], IOException + FullyQualifiedErrorId: System.IO.IOException, Microsoft.PowerShell.Commands.NewItemPropertyCommand New-ItemProperty: Die Eigenschaft ist bereits vorhanden unter C: \ Users \ Administrator \ Desktop \ Autologon.ps1: 7 Zeichen: 17 + New-ItemProperty <<<< - Pfad "HKLM: \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon"-Name DefautDomainName -value $ TheDomain + CategoryInfo: ResourceExists: (HKEY_LOCAL_MACH ... ersion \ Winlogon: String) [New-ItemProperty], IOException + FullyQualifiedErrorId: System.IO.IOException, Microsoft.PowerShell.Commands.NewItead

Ich weiß nicht, wie ich das beheben kann, und ich würde Ihre Hilfe wirklich schätzen.

0
Vasil Svilenov Nikolov

Wenn der Schlüssel bereits vorhanden ist, müssen Sie -Force verwenden, um ihn zu überschreiben. Sie können es am Ende hinzufügen

 $TheUser = Read-Host "What is the username?" $ThePassword = Read-Host "What is the password?" -AsSecureString $TheDomain = Read-Host "What is the domain?" New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon -Value 1 -Force New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUserName -Value "$TheUser" -Force New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -Value $ThePassword -Force New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefautDomainName -value $TheDomain -Force 
Wie ist Ihre Antwort konsistent mit der Anweisung des OP, dass das Skript beim zweiten Ausführen funktioniert? G-Man vor 6 Jahren 1
Es stimmt mit dem neuesten Beitrag überein. Ich weiß nicht, warum Sie dieses Batch-Skript zweimal ausführen müssen, aber ich weiß, warum Powershell ihm einen Fehler gab. Vasil Svilenov Nikolov vor 6 Jahren 0