近期換了一家公司,負責it所有的伺服器、網路、資產管理。為了便於桌面使用者的資產管理,我決定使用計算機的主機編號來命名,然後從域中就可以很清晰的看到每乙個資產的狀態。我的命名規則是sz-主機編號。
指令碼**如下:
'get current pcnamestrcomputer
= "."
set
objwmiservice
= getobject
("winmgmts:\\" & strcomputer & "\root\cimv2")
set
colcomputers
= objwmiservice
.execquery("select * from win32_computersystem")
for each objcomputer in colcomputers
strpcname
= ucase
(objcomputer.name)
next
'get sn number
set
objwmiservice
= getobject
("winmgmts:\\" & strcomputer & "\root\cimv2")
set
colitems
= objwmiservice
.execquery("select * from win32_bios")
for each objitem in colitems
strsn
= objitem
.serialnumber
next
strrname
= "cnsz-"
& strsn
if strpcname
= strrname
then
wscript.quit
end if
set
objwmiservice
= getobject
("winmgmts:" & "!\\" & strcomputer & "\root\cimv2")
set
colcomputers
= objwmiservice
.execquery("select * from win32_computersystem")
for each objcomputer in colcomputers
err=
objcomputer
.rename(strrname)
wscript.echo "the new pc name is " & strrname & "." & vbcrlf & "need reboot to take effect!"
next
'reboot or not
strreboot
= msgbox
("do you want to reboot computer?", vbyesno, "warning!")
if strreboot
= vbno
then
wscript.quit
end if
'==reboot
computer
==
strcomputer
= "."
set
objwmiservice
= getobject
("winmgmts:" _
& "!\\" & strcomputer & "\root\cimv2")
set
coloperatingsystems
= objwmiservice
.execquery _
("select * from win32_operatingsystem")
for each objoperatingsystem in coloperatingsystems
objoperatingsystem.reboot()
next
實現計算機
實現乙個計算器 實現兩個運算元 小數和整數均可 的加 減 乘 除 清零操作。1.加法運算 2.減法運算 3.乘法運算 4.除法運算 64 16 4 using system using system.collections.generic using system.componentmodel us...
WMI指令碼 計算機管理指令碼範例
更改計算機帳號屬性,演示如何通過指令碼來更改 active directory 中的計算機帳號的位置屬性。指令碼 set objcomputer getobject ldap cn cn computers,dc fabrikam,dc com objcomputer.put location bu...
棧實現計算機複雜計算
package com.yg.stack author geqilin date 2020 2 22 14 14 import jdk.nashorn.internal.ir.returnnode public class calculator else else else else index i...