当前位置: 首页 > news >正文

一键获取软硬件配置及管理员组

作为公司的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

最新内容请见作者的GitHub页:http://qaseven.github.io/

相关文章:

  • AMD发布第七代Pro A系列APU:面向企业
  • 草食系的“恋爱秘方”
  • 体验SCCM 2007 R2新特性-Reporting Services 报表订阅
  • 美国司法部:苹果三星专利侵权案应发回重申
  • windows编程入门之结构
  • 外媒称黑石集团或10亿美元出售文思海辉
  • SQL Server 2008下载 序列号
  • springboot国际化(i18n)
  • 域环境安装企业根CA
  • RocketMQ高并发读写
  • DHCP、网关和DNS地址的捆绑技巧
  • 浪潮持续推进政府数据开放 推动云计算和大数据发展战略
  • 【linux】让程序后台运行
  • Facebook新功能将变革数亿人使用社交媒体的方式
  • 通过ASP.NET获取URL地址方法
  • canvas 绘制双线技巧
  • crontab执行失败的多种原因
  • express.js的介绍及使用
  • Fabric架构演变之路
  • JavaScript学习总结——原型
  • k8s如何管理Pod
  • XML已死 ?
  • 不上全站https的网站你们就等着被恶心死吧
  • 翻译:Hystrix - How To Use
  • 开年巨制!千人千面回放技术让你“看到”Flutter用户侧问题
  • 浅谈web中前端模板引擎的使用
  • 强力优化Rancher k8s中国区的使用体验
  • 我看到的前端
  • UI设计初学者应该如何入门?
  • 基于django的视频点播网站开发-step3-注册登录功能 ...
  • ​中南建设2022年半年报“韧”字当头,经营性现金流持续为正​
  • #define用法
  • $.ajax中的eval及dataType
  • (1)(1.11) SiK Radio v2(一)
  • (1/2)敏捷实践指南 Agile Practice Guide ([美] Project Management institute 著)
  • (C语言)逆序输出字符串
  • (搬运以学习)flask 上下文的实现
  • (附源码)计算机毕业设计SSM基于java的云顶博客系统
  • (转)淘淘商城系列——使用Spring来管理Redis单机版和集群版
  • (轉貼) 蒼井そら挑戰筋肉擂台 (Misc)
  • .NET CORE 第一节 创建基本的 asp.net core
  • .net 使用$.ajax实现从前台调用后台方法(包含静态方法和非静态方法调用)
  • [ 蓝桥杯Web真题 ]-Markdown 文档解析
  • [14]内置对象
  • [52PJ] Java面向对象笔记(转自52 1510988116)
  • [ACTF2020 新生赛]Include
  • [C/C++]数据结构 循环队列
  • [CSS]浮动
  • [EFI]ASUS EX-B365M-V5 Gold G5400 CPU电脑 Hackintosh 黑苹果引导文件
  • [JavaWeb]——过滤器filter与拦截器Interceptor的使用、执行过程、区别
  • [Noi2015]程序自动分析
  • [NowCoder]牛客OI周赛3
  • [POJ2104]K-th Number
  • [Servlet 4]Bean与DAO设计模式
  • [TCP] TCP/IP 基础知识词典(2)