• vbs获取软件列表


    功能:获取本地安装列表,并以“计算机名+IP”命名输出txt文件

        
    on error resume Next
    Const HKLM         = &H80000002   
    Const HKCU         = &H80000001
    Const strKeyPath   = "SOFTWAREMicrosoftWindowsCurrentVersionUninstall"
    Const strKeyPathwin  ="SOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionUninstall"
    Const ForReading   = 1   
    Const ForAppending = 8  
      
    '定义输出路径
    Const FilePath     ="Y:123"
    
    Set Wshell         = CreateObject("Wscript.Shell")   
    Set objFSO         = CreateObject("Scripting.FileSystemobject")   
    
    Dim WshNetwork
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    strComputer = WshNetwork.ComputerName  
    
    
    if (objFSO.FileExits(FilePath & WshNetwork.ComputerName & "(" & GetIP() & ")" & ".txt")) then
    Set MyFile = objFSO.GetFile(FilePath & WshNetwork.ComputerName & "(" & GetIP() & ")" & ".txt") 
    MyFile.Delete
    End If 
    
    Set textWriteFile  = objFSO.OpenTextFile(FilePath & WshNetwork.ComputerName & "(" & GetIP() & ")" & ".txt",forappending,True)
      
    
    Set objReg  = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")   
    objReg.EnumKey HKCU, strKeyPath,arrSubKeys    
    
      For Each strSubKey In arrSubKeys        
        intRet = objReg.GetStringValue(HKCU, strKeyPath & strSubKey,"DisplayName",strValue)                                                    
             If strValue <> "" And intRet = 0 And Left(strSubKey, 2) <> "KB" Then   
                  textWriteFile.WriteLine(strValue)
            End If 
     Next
      
    
    Set objReglm  = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")   
    objReg.EnumKey HKLM, strKeyPath,arrSubKeys    
    
      For Each strSubKey In arrSubKeys        
        intRet = objReg.GetStringValue(HKLM, strKeyPath & strSubKey,"DisplayName",strValue)                                                    
            If strValue <> "" And intRet = 0 And Left(strSubKey, 2) <> "KB" Then   
                  textWriteFile.WriteLine(strValue)
            End If 
     Next
    
    Set objReg  = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")   
    objReg.EnumKey HKLM, strKeyPathwin,arrSubKeys    
    
      For Each strSubKey In arrSubKeys        
        intRet = objReg.GetStringValue(HKLM, strKeyPathwin & strSubKey,"DisplayName",strValue)                                                    
          If strValue <> "" And intRet = 0 And Left(strSubKey, 2) <> "KB" Then   
                  textWriteFile.WriteLine(strValue)
            End If 
     Next
    dim wsnet
    set wsnet=wscript.createobject("wscript.network")
    textWriteFile.WriteLine(wsnet.username)
    textWriteFile.Close   
    
    '获取本机IP
    'owner DeViL
    'return 本机的IP地址
    Public Function GetIP
       ComputerName="."
        Dim objWMIService,colItems,objItem,objAddress
        Set objWMIService = GetObject("winmgmts:\" & ComputerName & "
    ootcimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
        For Each objItem in colItems
            For Each objAddress in objItem.IPAddress
                If objAddress <> "" then
                    GetIP = objAddress
                    Exit Function
                End If
            Next
        Next
    End Function
    

      

  • 相关阅读:
    Bootstrap_让Bootstrap轮播插件carousel支持左右滑动手势的三种方法
    JAVA_用Java来获取访问者真实的IP地址
    Html5_移动前端不得不了解的html5 head 头标签
    ThinkPad_T430重装系统
    JavaScript_JS判断客户端是否是iOS或者Android
    Html5_禁止Html5在手机上屏幕页面缩放
    HttpClient_httpclient 4.3.1 post get的工具类
    HttpClient_使用httpclient必须知道的参数设置及代码写法、存在的风险
    LATEX数学公式基本语法
    为WLW开发Latex公式插件
  • 原文地址:https://www.cnblogs.com/airoot/p/12965229.html
Copyright © 2020-2023  润新知