簡體   English   中英

無法獲取AutoAdminLogon密鑰值。 Visual Basic .net

[英]Cannot get AutoAdminLogon key value. Visual Basic .net

我需要檢查遠程計算機是否自動登錄。 我正在使用波紋管代碼,但正在獲取默認值作為答案。 看起來它無法獲得任何用於自動登錄的值,但該值實際上存在。 我將不勝感激任何幫助

Private Sub askComputer(ByVal computer, ByRef text)

    Dim environmentKey As RegistryKey

    environmentKey =   RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computer).OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", False)

    text = environmentKey.GetValue("AutoAdminLogon", "?").ToString
    MsgBox(text)
    'For Each valueName As String In environmentKey.GetValueNames()

    'MsgBox(valueName)
    'MsgBox(environmentKey.GetValue(valueName).ToString())
    'Next

    ' Close the registry key.
    environmentKey.Close()

End Sub

此代碼將解決問題。 它可以在網絡上的任何計算機上獲取AutoAdminLogon密鑰

 Private Sub askComputer1(ByVal computer)

    MsgBox(computer)
    Dim environmentKey As RegistryKey
    Dim val1 As String, val2 As String
    environmentKey = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, computer, RegistryView.Registry64).OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon")

    val1 = environmentKey.GetValue("AutoAdminLogon").ToString()
    val2 = environmentKey.GetValue("DefaultUserName").ToString()
    MsgBox(val1 & "   " & val2)
    environmentKey.Close()

End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM