备份和清除事件日志

[ 2005/07/09 10:02 | by gOxiA ]

描述

备份和清除应用程序事件日志。


脚本代码
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
   & "{ impersonationLevel=impersonate,(Backup) }!\\" & _
       strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
   ("Select * from Win32_NTEventLogFile where LogFileName='Application'")
For Each objLogfile in colLogFiles
   errBackupLog = objLogFile.BackupEventLog("c:\scripts\application.evt")
   If errBackupLog <> 0 Then        
       Wscript.Echo "The Application event log could not be backed up."
   Else
       objLogFile.ClearEventLog()
   End If
Next

配置静态 IP 地址

[ 2005/07/09 10:00 | by gOxiA ]

描述

将计算机的 IP 地址设置为 192.168.1.141,并将 IP 网关设置为 192.168.1.100。


脚本代码
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
   ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
   errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
   errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
   If errEnable = 0 Then
       WScript.Echo "The IP address has been changed."
   Else
       WScript.Echo "The IP address could not be changed."
   End If
Next

创建主机地址 (A) DNS 记录

[ 2005/07/09 09:59 | by gOxiA ]

描述

在 DNS 服务器上创建主机地址 (A) 记录。

有关在这段代码中使用的 CreateInstanceFromPropertyData 方法的更多信息,请单击此处


支持平台

Windows Server 2003

Windows XP

否(然而,可以在 Windows XP 计算机上对远程 DNS 服务器运行脚本)

Windows 2000

是,需要安装 DNS WMI 提供程序

Windows NT 4.0


脚本代码
strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "workstation5.fabrikam.com"
intRecordClass = 1
intTTL = 600
strIPAddress = "192.168.1.100"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDNS")
Set objItem = objWMIService.Get("MicrosoftDNS_AType")
errResult = objItem.CreateInstanceFromPropertyData _
   (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, strIPAddress)

分页: 5/11 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]