A VB Script that checks registry for installed hotfix

批量扫描热修复补丁
本文介绍了一种使用VBScript批量检查计算机上特定热修复补丁(如KB902400)安装状态的方法。该脚本通过读取输入文件中列出的计算机名称,并利用WMI查询每台计算机上的注册表,来确定指定热修复补丁是否已安装。查询结果将被写入到输出文件中。
部署运行你感兴趣的模型镜像

———————————————————————-

'Checks the registry of each computer listed in INPUT_FILE_NAME
'for a the hotfix listed in HOTFIX
'It uses the WMI registry provider to do this.
'Besides writing to the screen, it writes the output to
'the file in OUTPUT_FILE_NAME in comma delimted format, producing 2 columns:
'the computer name, and the result of the query
'
'21/10/2005 Robert Kloosterhuis: v1.0
'http://www.geekswithblogsnet/jemimus


On Error Resume Next

INPUT_FILE_NAME = "serverlist.txt"
OUTPUT_FILE_NAME = "scan_hotfix_MS05_051.csv"
HOTFIX = "KB902400"

Const FOR_READING = 1
'objFSO.OpenTextFile method uses paramater value 8 to append to file
Const FOR_WRITING = 8
const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Set StdOut = WScript.StdOut

'Set up objFSO variable for file reading and writing operations
Set objFSO = CreateObject("Scripting.FileSystemObject")

'delete OUTPUT_FILE_NAME if it already exists
Set oldfile = objFSO.GetFile(OUTPUT_FILE_NAME)
oldfile.delete

'Set up the output file
Set objOutputFile = objFSO.OpenTextFile(OUTPUT_FILE_NAME, FOR_WRITING, true)


'Read the input file
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
strComputers = objFile.ReadAll
objFile.Close

'Make an array out of the list it reads from the input file
arrComputers = Split(strComputers, vbCrLf)

'setting up some initial values
DIM result
DIM noresult
result = 0
noresult = 0

'Our main loop. Everything below this is run for every entry in the imput file
For Each strComputer In arrComputers

  'first column in the file we are writing to is the computer name.
  'Every bit of info we want to provide is ended with a comma for delimitation
   objOutputFile.Write
   objOutputFile.Write
   objOutputFile.Write strComputer
   objOutputFile.Write ","
  
  
  Err.Clear
  'Connect to the WMI registry provider
  Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!//" & _
     strComputer & "/root/default:StdRegProv")
        'Error Handling If it cant connect to the WMI provider,
        'exit with the Error Description
     If Err.Number <> 0 Then
           Wscript.Echo strComputer & " " & "Error Number " & _
           Err.Number &  ": " & Err.Description
           Err.Clear
           Else
  
          'The Registry path we are going to read from
    strKeyPath = "SOFTWARE/Microsoft/Windows NT/CurrentVersion/HotFix"
    objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

    
    'Everytime we run though the loop, these values are reset first.
    result = 0
    noresult = 0
    
    'If it comes across the hotfix we are looking for,
    'it changed the value for this loop
    For Each Subkey in arrSubKeys
                   
        IF Subkey = HOTFIX Then
        result = 1
        noresult = 0
       
        Else
        noresult = 1
       
     End IF           
              
    Next          
          
    
     'Now we have a value, lets print some text about it,
     'both to the screen, and to our output file
     IF result = 1 Then
       
       WScript.Echo strComputer & " " & HOTFIX & " installed!!!"
       objOutputFile.Write HOTFIX & " installed!!!"
     Else
       WScript.Echo strComputer & " " & HOTFIX & " not found!"
       objOutputFile.Write HOTFIX & " not found!"
     End IF

     
        'End with a comma for this column
        objOutputFile.Write ","
        
        
       
      
        

     end if
     
     'Start a new line  
     objOutputFile.Writeline
     
Next
objOutputFile.Close 

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

【无人机】基于改进粒子群算法的无人机路径规划研究[和遗传算法、粒子群算法进行比较](Matlab代码实现)内容概要:本文围绕基于改进粒子群算法的无人机路径规划展开研究,重点探讨了在复杂环境中利用改进粒子群算法(PSO)实现无人机三维路径规划的方法,并将其与遗传算法(GA)、标准粒子群算法等传统优化算法进行对比分析。研究内容涵盖路径规划的多目标优化、避障策略、航路点约束以及算法收敛性和寻优能力的评估,所有实验均通过Matlab代码实现,提供了完整的仿真验证流程。文章还提到了多种智能优化算法在无人机路径规划中的应用比较,突出了改进PSO在收敛速度和全局寻优方面的优势。; 适合人群:具备一定Matlab编程基础和优化算法知识的研究生、科研人员及从事无人机路径规划、智能优化算法研究的相关技术人员。; 使用场景及目标:①用于无人机在复杂地形或动态环境下的三维路径规划仿真研究;②比较不同智能优化算法(如PSO、GA、蚁群算法、RRT等)在路径规划中的性能差异;③为多目标优化问题提供算法选型和改进思路。; 阅读建议:建议读者结合文中提供的Matlab代码进行实践操作,重点关注算法的参数设置、适应度函数设计及路径约束处理方式,同时可参考文中提到的多种算法对比思路,拓展到其他智能优化算法的研究与改进中。
To check if an element exists in a tuple using a `for` loop in Rust, you don't need to use a separate data structure like lists (`Option` or `Vec`) since tuples are immutable by default. Here's how you can do it: ```rust // Define a tuple with some elements let tuple: (u8, String, i32) = (42, "hello".to_string(), 1337); fn contains_element(element: &u8, tup: &(_, _, _)) -> bool { // Iterate over the tuple using a pattern matching for loop for (e, _, _) in tup { // Compare the current element with the target element if *e == element { return true; // Found the element, exit the loop and return true } } false // Element not found after the loop, return false } // Check if an element exists in the tuple if let Some(index) = Some(0) { // Assuming you have the index of the element to search let element_to_find = 42; if contains_element(&element_to_find, &tuple) { println!("The element {} exists in the tuple.", element_to_find); } else { println!("The element {} does not exist in the tuple.", element_to_find); } } ``` In this example, the `contains_element` function takes a reference to the target element and a tuple as parameters. It iterates through the tuple using a pattern-matched `for` loop and checks if each element matches the target. If it finds a match, it returns `true`; otherwise, it returns `false`. Note that the code assumes you already know the index of the element you want to search within the tuple. If you're dynamically searching for an element without an index, you might need to use a different approach.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值