谢谢,杀多台机器(>70),其实最想知道的是taskkill能不能用筛选器选出那个进程,如果能直接批处理解决是最方便了,wmi我是一点也不懂 回复 16# cj-reggie
批量做动作作为网管更要用WMI了,其实很简单的,有个批量检查BLOS中USB开关的码,希望对你有所帮助
#include <file.au3>
#include <array.au3>
$file = @ScriptDir&"\result.ini"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
Dim $aRecord,$aRecords
Run(@ComSpec & " /c dsquery computer -o rdn-limit 1500 >"&@TempDir&"\adlist.txt","", @SW_HIDE);利用dsquery查询Active Directory所有PC name
Sleep(2000)
If Not _FileReadToArray(@TempDir&"\adlist.txt",$aRecord) Then;读取文件得到数组
MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
Exit
EndIf
For $x = 1 to $aRecord-1
$aRecord[$x] =StringTrimRight((StringTrimLeft($aRecord[$x], 1)),1)
If Ping ($aRecord[$x],250) Then
If Ping ($aRecord[$x]) And DriveStatus( "\\"&$aRecord[$x]&"\c$" ) = "UNKNOWN" Then;有些PC可能IP冲突,也有可能没有管理员权限,暂且定义为防火墙
IniWrite($file,"info",$aRecord[$x],"Firewall")
Else
$objWMIService = ObjGet("winmgmts:\\" & $aRecord[$x] & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_USBController", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $colItems
If $objItem.Status= "OK" Then
iniWrite($file,"info",$aRecord[$x],"OK");USB开着的
Else
iniWrite($file,"info",$aRecord[$x],"NO");USB没问题
EndIf
Next
EndIf
Else
If TCPNameToIP($aRecord[$x])<>"" Then
IniWrite($file,"info",$aRecord[$x],"No boot");没开机
Else
IniWrite($file,"info",$aRecord[$x],"N/PC");没有的PC在AD中没有即时update
EndIf
EndIf
Next
设想,如果读取不了,路径 .................怎么判断? 找到进程的宿主(如果是继承过来的),或者创建用户。。。。两个同名进程肯定至少有一个是不同的地方,找出来kill掉就完了
页:
1
[2]