qileilove

          blog已經轉移至github,大家請訪問 http://qaseven.github.io/

          一鍵獲取軟硬件配置及管理員組

          作為公司的IT運維,經常要面對集團各種名頭的稽查,對我們工作量造成相當大的提高。公司的IT政策不允許使用非法軟件、USB口要關閉、電腦使用者不能有管理員權限等等。于是每一個最底層的工作人員一天到晚圍著用戶的電腦跑,查找硬件配置,軟件信息等,為了提高工作效率,于是就寫了以下批處理,減輕自己的工作負擔。
            功能說明:
            1.掃描機器硬件配置
            2.獲取電腦的網絡配置
            3.掃描機器軟件安裝列表
            4.查看Administrators組和Power Users組內的用戶
            5.電腦的USB存儲端口開關情況
            6.電腦的共享信息
            7.掃描結果自動上傳
            掃描的結果以程序畫面顯示(重要內容)及轉出以電腦名稱命名的文本文件(詳細內容)。并將此文本文件自動上傳到共享文件夾中。
            以下是批處理的代碼:
          @echo off
          color 57
          title HardSoft Viewer
          mode con cols=67 lines=42
          setlocal  ENABLEDELAYEDEXPANSION
          echo Prepare For View ...
          del /f "%TEMP%\temp.txt" 2>nul
          dxdiag /t %TEMP%\temp.txt
          del /f "%COMPUTERNAME%.txt" 2>nul
          echo Start Hardware Viewer ...
          echo System Information: >>%COMPUTERNAME%.txt
          :system
          rem This must 30s
          if EXIST "%TEMP%\temp.txt" (
          for /f "tokens=1,2,* delims=:" %%a in ('findstr /c:" Machine name:" /c:" Operating System:" /c:" System Model:" /c:" Processor:" /c:"  Memory:" /c:" Card name:" /c:"Display Memory:" "%TEMP%\temp.txt"') do (
          set /a tee+=1
          if !tee! == 1 echo       Computer Name = %%b>>%COMPUTERNAME%.txt
          if !tee! == 2 echo       OS       Type = %%b>>%COMPUTERNAME%.txt
          if !tee! == 3 echo       System  Model = %%b>>%COMPUTERNAME%.txt
          if !tee! == 4 echo       CPU     Model = %%b>>%COMPUTERNAME%.txt
          if !tee! == 5 echo       RAM      Size = %%b>>%COMPUTERNAME%.txt
          if !tee! == 6 echo.>>%COMPUTERNAME%.txt
          if !tee! == 6 echo DisplayCard : >>%COMPUTERNAME%.txt
          if !tee! == 6 echo       Display  Card = %%b>>%COMPUTERNAME%.txt
          if !tee! == 7 echo       DisplayMemory = %%b>>%COMPUTERNAME%.txt
          )   ) else (
          ping /n 2 127.1>nul
          goto system
          )
          set tee=0
          echo.>>%COMPUTERNAME%.txt
          echo Mother Board:>>%COMPUTERNAME%.txt
          for /f "tokens=1,* delims==" %%a in ('wmic BASEBOARD get Manufacturer^,Product^,Version^,SerialNumber /value') do (
          set /a tee+=1
          if "!tee!" == "3" echo       Manufacturer     = %%b>>%COMPUTERNAME%.txt
          if "!tee!" == "4" echo       MotherBoard Model= %%b>>%COMPUTERNAME%.txt
          )
          set tee=0
          )
          echo.>>%COMPUTERNAME%.txt
          echo Hard Disk: >>%COMPUTERNAME%.txt
          for /f "skip=2 tokens=*" %%a in ('wmic DISKDRIVE get model ^,size /value') do (
          echo.      %%a>>%COMPUTERNAME%.txt
          )
          set tee=0
          echo.>>%COMPUTERNAME%.txt
          echo Network Card:>>%COMPUTERNAME%.txt
          for /f "tokens=2* delims==:" %%a in ('ipconfig/all^|find /i "Description" ^| findstr /v "Microsoft" ^| findstr /v "Tunneling"') do (
          set  name=%%a
          echo      NetCard Model = %%a>>%COMPUTERNAME%.txt
          )
          for /f "tokens=2* delims==:" %%a in ('ipconfig/all^|find /i "Physical Address" ^| findstr /v "00-00-00-00"') do (
          set  name=%%a
          echo      MAC Address = %%a>>%COMPUTERNAME%.txt
          )
          for /f "tokens=2* delims==:" %%a in ('ipconfig/all^|find /i "描述" ^| findstr /v "Microsoft" ^| findstr /v "Tunneling"') do (
          set  name=%%a
          echo      NetCard Model = %%a>>%COMPUTERNAME%.txt
          )
          for /f "tokens=2* delims==:" %%a in ('ipconfig/all^|find /i "物理地址" ^| findstr /v "00-00-00-00"') do (
          set  name=%%a
          echo      MAC Address = %%a>>%COMPUTERNAME%.txt
          )
          ver|find /i "windows xp">nul 2>nul&&goto xp||goto win7
          :xp
          for /f "tokens=2* delims==:" %%a in ('ipconfig/all^|find /i "IP Address"') do (
          set  name=%%a
          echo      IP Address = %%a>>%COMPUTERNAME%.txt
          )
          echo Start Software Viewer For XP...
          echo.>>%COMPUTERNAME%.txt
          echo Software Information:>>%COMPUTERNAME%.txt
          for /f "tokens=7 delims=\" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" ^| findstr /v "KB" 2^>nul') do (
          for /f "skip=4 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%i" /v DisplayName 2^>nul' ) do (
          echo %%b>>%COMPUTERNAME%.txt
          )
          )
          for /f "tokens=2 delims=\" %%x in ('reg query HKU') do (
          for /f "tokens=8 delims=\" %%a in ('reg query "HKU\%%x\Software\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
          for /f "skip=4 tokens=2*" %%i in ('reg query "HKU\%%x\Software\Microsoft\Windows\CurrentVersion\Uninstall\%%a"  /v "DisplayName" 2^>nul') do (
          echo %%j>>%COMPUTERNAME%.txt
          )
          )
          )
          echo.>>%COMPUTERNAME%.txt
          if exist %windir%\system32\CCM\CcmExec.exe echo "SMS Client has been installed,please uninstall"
          if exist %windir%\system32\CCM\CcmExec.exe echo "SMS Client has been installed,please uninstall">>%COMPUTERNAME%.txt
          echo ==================================================================
          echo USB Information:
          echo.>>%COMPUTERNAME%.txt
          echo USB Information:>>%COMPUTERNAME%.txt
          for /f "skip=4 tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Services\usbstor" /v "start" 2^>nul' ) do (
          if "%%b"=="0x4" echo     USB is Close
          if "%%b"=="0x3" echo     USB is Open,Please Tag It.
          if "%%b"=="0x4" echo     USB is Close>>%COMPUTERNAME%.txt
          if "%%b"=="0x3" echo     USB is Open,Please Tag It.>>%COMPUTERNAME%.txt
          )
          goto last
          :win7
          for /f "tokens=2* delims==:" %%a in ('ipconfig/all^|find /i "IPV4"') do (
          set  name=%%a
          echo      IP Address = %%a>>%COMPUTERNAME%.txt
          )
          echo Start Software Viewer For Win7/8 ...
          rem for 32 win7
          echo.>>%COMPUTERNAME%.txt
          echo Software Information:>>%COMPUTERNAME%.txt
          for /f "tokens=7 delims=\" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" ^| findstr /v "KB" 2^>nul ') do (
          for /f "skip=2 tokens=3* delims= " %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%i" /v DisplayName 2^>nul') do (
          echo %%a %%b>>%COMPUTERNAME%.txt
          )
          )
          for /f "tokens=8 delims=\" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul ^| findstr /v "KB" 2^>nul ') do (
          for /f "skip=2 tokens=3* delims= " %%a in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%%i" /v DisplayName 2^>nul') do (
          echo %%a %%b>>%COMPUTERNAME%.txt
          )
          )
          for /f "tokens=2 delims=\" %%x in ('reg query HKU') do (
          for /f "tokens=8 delims=\" %%a in ('reg query "HKU\%%x\Software\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
          for /f "skip=2 tokens=2*" %%i in ('reg query "HKU\%%x\Software\Microsoft\Windows\CurrentVersion\Uninstall\%%a"  /v "DisplayName" 2^>nul') do (
          echo %%j>>%COMPUTERNAME%.txt
          )
          )
          )
          for /f "tokens=2 delims=\" %%x in ('reg query HKU') do (
          for /f "tokens=9 delims=\" %%a in ('reg query "HKU\%%x\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
          for /f "skip=2 tokens=2*" %%i in ('reg query "HKU\%%x\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%%a"  /v "DisplayName" 2^>nul') do (
          echo %%j>>%COMPUTERNAME%.txt
          )
          )
          )
          echo ==================================================================
          echo USB Information:
          echo.>>%COMPUTERNAME%.txt
          echo USB Information:>>%COMPUTERNAME%.txt
          for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Services\usbstor" /v "start" 2^>nul' ) do (
          if "%%b"=="0x4" echo     USB is Close
          if "%%b"=="0x3" echo     USB is Open,Please Tag It.
          if "%%b"=="0x4" echo     USB is Close>>%COMPUTERNAME%.txt
          if "%%b"=="0x3" echo     USB is Open,Please Tag It.>>%COMPUTERNAME%.txt
          )
          :last
          echo ==================================================================
          echo Admin Users:
          echo.>>%COMPUTERNAME%.txt
          echo Admin Users:>>%COMPUTERNAME%.txt
          for /f "skip=6 tokens=*" %%i in ('net localgroup Administrators ^| findstr /v "㏑" ^| findstr /v "命" ^| findstr /v "command"') do (
          echo       %%i
          echo       %%i>>%COMPUTERNAME%.txt
          )
          echo Power Users:
          echo.>>%COMPUTERNAME%.txt
          echo Power Users:>>%COMPUTERNAME%.txt
          for /f "skip=6 tokens=*" %%i in ('net localgroup "Power Users" ^| findstr /v "㏑" ^| findstr /v "命" ^| findstr /v "command"') do (
          echo       %%i
          echo       %%i>>%COMPUTERNAME%.txt
          )
          echo ==================================================================
          echo FileShare Information:
          echo.>>%COMPUTERNAME%.txt
          echo FileShare Information:>>%COMPUTERNAME%.txt
          for /f "skip=4 tokens=*" %%i in ('net share 2^>nul ^| findstr /v "㏑" ^| findstr /v "命" ^| findstr /v "command"' ) do (
          echo  %%i
          echo  %%i>>%COMPUTERNAME%.txt
          )
          echo =========================Viewer Over==============================
          net use \\192.168.1.1 password /user:username 1>nul 2>nul
          copy %COMPUTERNAME%.txt \\192.168.1.1\HardFile$\
          net use \\192.168.1.1\IPC$ /del 1>nul 2>nul
          pause
          start %COMPUTERNAME%.txt
           現在來查看下掃描結果XP/WIN8對比
            以及產生的掃描結果
          System Information:
          Computer Name =  C0300022B068
          OS       Type =  Windows 8.1 專業版 64-bit (6.3, Build 9600) (9600.winblue_gdr.131030-1505)
          System  Model =  System Product Name
          CPU     Model =  Pentium(R) Dual-Core  CPU      E5500  @ 2.80GHz (2 CPUs), ~2.8GHz
          RAM      Size =  4096MB RAM
          DisplayCard =
          Display  Card =  Microsoft 基本顯示適配器
          DisplayMemory =  256 MB
          Mother Board:
          Manufacturer     = ASUSTeK Computer INC.
          MotherBoard Model= P5KPL-AM
          Hard Disk:
          Model=ST3500418AS ATA Device
          Size=500038694400
          Network Card:
          NetCard Model =  Realtek PCIe FE Family Controller
          MAC Address =  00-23-54-0A-31-A9
          IP Address =  172.17.44.103(首選)
          Software Information:
          谷歌拼音輸入法 2.7
          7-Zip 9.30 (x64 edition)
          Windows Live MIME IFilter
          Java 8 Update 20 (64-bit)
          Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.4148
          Java SE Development Kit 8 Update 20 (64-bit)
          Microsoft Application Error Reporting
          PDF-Viewer
          Microsoft Visual C++ 2005 Redistributable (x64)
          MSVCRT110_amd64
          VIA 平臺設備管理員
          Mozilla Maintenance Service
          Notepad++
          Windows Live 軟件包
          Windows Live UX Platform
          Windows Live Writer
          Windows Live UX Platform Language Pack
          Junk Mail filter update
          Radmin Viewer 3.5
          Windows Live Photo Common
          Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4148
          Platform
          Windows Live 軟件包
          Windows Live Writer
          Windows Live Writer
          微軟設備健康助手
          Windows Live Communications Platform
          Java Auto Updater
          Windows Live Mail
          Windows Live Writer Resources
          LibreOffice 4.3.0.4
          Windows Live Installer
          Windows Live Writer
          Windows Live Writer Resources
          Windows Live UX Platform Language Pack
          Windows Live 程式集
          Microsoft Visual C++ 2005 Redistributable
          Photo Common
          MSVCRT
          MSVCRT110
          Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022
          Adobe Reader 8 - Chinese Traditional
          Windows Live PIMT Platform
          Windows Live Mail
          Windows Live Mail
          Windows Live SOXE
          MSVCRT_amd64
          Windows Live SOXE Definitions
          Photo Common
          D3DX10
          Microsoft WSE 3.0 Runtime
          Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022.218
          Microsoft WSE 2.0 SP3 Runtime
          USB Information:
          USB is Open,Please Tag It.
          Admin Users:
          Administrator
          Luke
          Power Users:
          FileShare Information:
          ADMIN$       C:\Windows                      遠程管理
          C$           C:\                             默認共享
          IPC$                                         遠程 IPC
          D$           D:\                             默認共享
          E$           E:\                             默認共享
          F$           F:\                             默認共享
          HardFile$    D:\HardFile
          cd_rom       D:\cd_rom
          HardSoftViewer
          D:\HardSoftViewer
          HardwareViewer 20140923
          D:\HardwareViewer 20140923
          public       D:\public

          posted on 2014-10-09 10:24 順其自然EVO 閱讀(352) 評論(0)  編輯  收藏 所屬分類: 測試學習專欄

          <2014年10月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 荣昌县| 仪陇县| 呼玛县| 正宁县| 宜君县| 横山县| 额济纳旗| 延寿县| 岚皋县| 正宁县| 藁城市| 开原市| 邵阳县| 沧源| 左权县| 新兴县| 淮滨县| 衡南县| 宁都县| 文成县| 军事| 榆林市| 湘乡市| 龙胜| 天门市| 旌德县| 客服| 普格县| 社旗县| 平安县| 江源县| 蓝山县| 尖扎县| 邢台市| 四川省| 永寿县| 墨江| 滦平县| 锦州市| 永康市| 惠安县|