检索本地服务器用户的环境启动程序?

时间:2011-10-06 17:58:39

标签: vbscript windows-server-2003

我正在使用vbscript来检索本地用户帐户详细信息。此脚本使用Win32_Account

该脚本的摘录:

If (bWMILocalAccounts) Then
    ReportProgress " Gathering local users"
    Set colItems = objWMIService.ExecQuery("Select Description, Name, FullName, LocalAccount from Win32_UserAccount Where Domain='" & strComputerSystem_Name & "'",,48)
    Set objDbrLocalAccounts = CreateObject("ADOR.Recordset")
    objDbrLocalAccounts.Fields.Append "Description", adVarChar, MaxCharacters
    objDbrLocalAccounts.Fields.Append "UserName", adVarChar, MaxCharacters

是否可以阅读'环境 - >启动程序的路径?

enter image description here

1 个答案:

答案 0 :(得分:1)

您正在寻找的信息来自ADSI,所以我搜索了一下,并在virtualizationadmin.com上找到了这个link。它提供了一个很好的表格,显示“Active Directory用户和计算机”选项卡中的哪些字段与其属性匹配,以便在脚本中使用(批处理,vbs等)。

掌握了这些信息,activexperts.com gives a great sample VBScript显示此信息,在此复制,您可以在脚本中使用。

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

intConnectClientDrivesAtLogon = objUser.ConnectClientDrivesAtLogon
intConnectClientPrintersAtLogon = objUser.ConnectClientPrintersAtLogon
intDefaultToMainPrinter = objUser.DefaultToMainPrinter
strTerminalServicesInitialProgram = objUser.TerminalServicesInitialProgram
strTerminalServicesWorkDirectory = objUser.TerminalServicesWorkDirectory

WScript.echo "ConnectClientDrivesAtLogon: " & intConnectClientDrivesAtLogon
WScript.echo "ConnectClientPrintersAtLogon: " & _
    intConnectClientPrintersAtLogon
WScript.echo "DefaultToMainPrinter: " & intDefaultToMainPrinter
WScript.echo "TerminalServicesInitialProgram: " & _
    strTerminalServicesInitialProgram 
WScript.echo "TerminalServicesWorkDirectory: " & _
    strTerminalServicesWorkDirectory