0

您好,我正在编写这个脚本,我需要序列号、IP 地址、登录用户、办公室的产品密钥、自动路由到文本文件。我已经开始编写脚本,但遇到了一些问题。不是一个完成的脚本,但我有点坚持这里。

这是脚本:

    On Error Resume Next

    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20

    arrComputers = Array("localhost")
    For Each strComputer In arrComputers

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService1.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly)                         
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService2.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly)

    Set objWMIService = GetObject( "winmgmts:\\" & strCoputer & ".\root\CIMV2" )
    Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly)

    next

    For Each objItem In colItems2

    Dim fso, tf
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set tf = fso.CreateTextFile ("c:\" & objItem.UserName & ".txt", True)
    tf.Write "Username: " & objItem.UserName
    tf.WriteBlankLines(1)
    tf.Write "Hostname: " & objItem.Name
    tf.WriteBlankLines(1)
    tf.Write "Domain: " & objItem.Domain
    tf.WriteBlankLines(2)

    next 

    For Each objItem In colItems1

    tf.Write "Serial: " & objItem.IdentifyingNumber
    tf.WriteBlankLines(1)
    tf.Write "Model: " & objItem.Name
    tf.WriteBlankLines(2)  
    tf.Write "Vendor: " & objItem.Vendor
    tf.WriteBlankLines(1)   
    tf.Write "Version: " & objItem.Version
    tf.WriteBlankLines(2)  

    Next

    For Each objItem In colItems3

    tf.Write "IP Address: " & objItem.IPAddress
    tf.WriteBlankLines(1)
    tf.Close

    next 
4

1 回答 1

1

微软创建了一个名为 Scriptomatic 的免费工具,它可以自动为此类任务创建 vbscript 代码。您可以从以下位置下载 scriptomatic。 http://www.microsoft.com/en-in/download/details.aspx?id=12028

于 2013-08-06T08:30:43.620 回答