我有一个脚本,我运行的设置计算机自动登录作为管理员。我在这些电脑上使用Vista家庭特价。我用MDT 2010安装它们,在完成之后,我已经放置了一个脚本,通过写入注册表来设置自动管理登录。
问题是,由于某种原因,注册表中的项在重新启动后被重置。如果我再次运行脚本,它可以工作,并且键不会被重置。(我让脚本在结束时删除自己,以使工作流更快)。
有人知道为什么要重置钥匙吗?
我把我的剧本写在下面。
Option Explicit
Dim Temp
Dim oReg
Dim strComputer
Dim strResult
Dim intResult
Dim readValue
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
strResult = ""
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Temp = WriteReg("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultUserName","TobiiUser")
Temp = WriteReg("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultPassword","Tobii")
Temp = WriteReg("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\", "AutoAdminLogon","1")
Temp = WriteReg("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultDomainName",".")
Function WriteReg(strKeyPath, strValueName, strValue)
' Create key to use
intResult = oReg.CreateKey(HKEY_LOCAL_MACHINE, strKeyPath)
If (intResult = 0) And (Err.Number = 0) Then
' write string value to key
intResult = oReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
If (intResult = 0) And (Err.Number = 0) Then
intResult = oReg.GetStringValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,readValue)
If readValue = strValue Then
strResult = strResult & "Succeded writing key: " & HKEY_LOCAL_MACHINE & strKeyPath & strValueName & VbCrLf
End If
Else
strResult = strResult & "Failed writing key: " & HKEY_LOCAL_MACHINE & strKeyPath & strValueName & " with error no: " & intResult & VbCrLf
End If
Else
strResult = strResult & "Failed creating key: " & HKEY_LOCAL_MACHINE & strKeyPath & strValueName & " with error no: " & intResult & VbCrLf
End If
End Function
'Delete the script
DeleteSelf
MsgBox strResult, vbInformation, "Autologon"
Sub DeleteSelf()
Dim objFSO
'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Delete the currently executing script
objFSO.DeleteFile WScript.ScriptFullName
Set objFSO = Nothing
End Sub发布于 2010-02-10 13:00:12
问题是AutoLogonCount是0,如果是零窗口,则清除DefaultPassword并在关机时将AutoAdminLogon设置为0,因此删除了最近的更改。解决方案是删除密钥AutoLogonCount。
https://serverfault.com/questions/99134
复制相似问题