脚本:计算机管理脚本

  • 更改计算机帐号属性

更改计算机帐号属性,演示如何通过脚本来更改 Active Directory 中的计算机帐号的位置属性。

脚本代码:

Set objComputer = GetObject("LDAP://CN=.,CN=Computers,DC=fabrikam,DC=com")
objComputer.Put "location", "Building 37, Floor 2, Room 2133"
objComputer.Set Info
  • 离线激活 Windows

使用离线方法来激活 Windows。需要 XP 或 Windows 2003、以及一个有效的激活编号。

脚本代码:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2")
Set colWindowsProducts = objWMIService.ExecQuery ("SELECT * FROM Win32_WindowsProductActivation")
For Each objWindowsProduct In colWindowsProducts   
objWindowsProduct.ActivateOffline("1234-1234")
Next
  • 在线激活 Windows

使用在线方法来激活 Windows。需要 XP 或 Windows 2003、以及活动的 Internet 连接。

脚本代码:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2")
Set colWindowsProducts = objWMIService.ExecQuery ("SELECT * FROM in32_WindowsProductActivation")
For Each objWindowsProduct In colWindowsProducts
objWindowsProduct.ActivateOnline()
Next
  • 配置系统启动延时

将计算机配置为在启动时自动加载默认操作系统之前等待 10 秒钟(而不是默认的 30 秒钟)。

脚本代码:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2")
Set colStartupCommands = objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystem")
For Each objStartupCommand In colStartupCommands
objStartupCommand.SystemStartupDelay = 10
objStartupCommand.Put_
Next
  • 获取操作系统属性

信息获取有关计算机上所安装的操作系统信息,其中包括语言种类、加密级别和内建编号等。

脚本代码:

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
strComputer = "."
Set objWMIService=GetObject("winmgmts:"& "{impersonationLevel=impersonate}!//" & strComputer&"/root/cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo "Boot Device: " & objOperatingSystem.BootDevice
Wscript.Echo "Build Number:" & objOperatingSystem.BuildNumber
Wscript.Echo "Build Type: " & objOperatingSystem.BuildType
Wscript.Echo "Caption: " & objOperatingSystem.Caption
Wscript.Echo "Code Set : " & objOperatingSystem.CodeSet
Wscript.Echo "Country Code: " & objOperatingSystem.CountryCode
Wscript.Echo "Debug: " & objOperatingSystem.Debug
Wscript.Echo "Encryption Level:" & objOperatingSystem.EncryptionLevel
dtmConvertedDate.Value = objOperatingSystem.InstallDate
dtmInstallDate = dtmConvertedDate.GetVarDate
Wscript.Echo "Install Date: " & dtmInstallDate
Wscript.Echo "Licensed Users: " & objOperatingSystem.NumberOfLicensedUsers
Wscript.Echo "Organization: " & objOperatingSystem.Organization
Wscript.Echo "OS Language: " & objOperatingSystem.OSLanguage
Wscript.Echo "OS Product Suite:" & objOperatingSystem.OSProductSuite
Wscript.Echo "OS Type: " & objOperatingSystem.OSType
Wscript.Echo "Primary: " & objOperatingSystem.Primary
Wscript.Echo "Registered User: " & objOperatingSystem.RegisteredUser
Wscript.Echo "Serial Number: " & objOperatingSystem.SerialNumber
Wscript.Echo "Version: " & objOperatingSystem.Version
Next
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值