@echo off
set fn=\\192.168.1.7\公用\soft\ComputerIP\%computername%.txt
set cn=\\192.168.1.7\公用\soft\ComputerIP\computername.txt
::关闭U盘
::cacls %SystemRoot%\inf\usbstor.inf /e /c /d system
::cacls %SystemRoot%\inf\usbstor.inf /e /c /d "power users"
::cacls %SystemRoot%\inf\usbstor.inf /e /c /d users
::cacls %SystemRoot%\inf\usbstor.inf /r "everyone" /e
::cacls %SystemRoot%\inf\usbstor.PNF /e /c /d system
::cacls %SystemRoot%\inf\usbstor.PNF /e /c /d "power users"
::cacls %SystemRoot%\inf\usbstor.PNF /e /c /d users
::cacls %SystemRoot%\inf\usbstor.PNF /r "everyone" /e
::用户电脑同步域控时间
net time \\127.0.0.1 >%fn%
net time \\192.168.1.5 >>%fn%
net time /set \\192.168.1.5 /y
::把当前用户从管理员组删除并加入到POWER USER组
::net localgroup "administrators" %USERNAME% /del
::net localgroup "power users" %USERNAME% /add
::获取用户组
Net localgroup administrators >>%fn%
::获取计算机名并插入到以电脑名命名的TXT文件里
@echo 计算机名=%computername%>>%fn%
::获取用户名:
@echo 用户名=%USERNAME%>>%fn%
::获取计算机描述
for /f "tokens=2* skip=3" %%i in ('reg query "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\lanmanserver\Parameters" /v srvcomment') do (
echo 计算机描述=%%j>>%fn%
set miaoshu=%%j
)
::获取工作组
::for /f "skip=1" %%i in ('wmic computersystem where Name^="%COMPUTERNAME%" get domain') do (
::echo 工作组=%%i>>%fn%
::set workgroup=%%i
::)
::获取IP地址
for /f "tokens=2 delims=:" %%i in ('ipconfig^|findstr "IP Address"') do (
echo IP地址=%%i>>%fn%
set ip=%%i
)
::获取子网掩码
for /f "tokens=2 delims=:" %%i in ('ipconfig^|findstr "Subnet Mask"') do (
echo 子网掩码=%%i>>%fn%
set mark=%%i
)
::获取网关
for /f "tokens=2 delims=:" %%i in ('ipconfig^|findstr "Default Gateway"') do (
echo 网关=%%i>>%fn%
set gateway=%%i
)
::获取MAC地址
for /f "tokens=2 delims=:" %%i in ('ipconfig /all^|find "Physical Address"')do set a=%%i
if "%a:~0,1%"==" " set "a=%a:~1%"
if "%a:~-1%"==" " set "a=%a:~0,-1%"
set mac=%a%
@echo MAC 地址=%a%>>%fn%
::判断是否有电脑名记录有的话跳过插入
for /f %%a in ('findstr %computername% %cn%') do (
set netname=%%a
)
if "%netname%"=="" (goto _insert) else goto _end
::导入总TXT文件
:_insert
::用TAB做连接字符串用可直接复制到excel里面会自动分列
set lianjian=
echo %computername%%lianjian%%USERNAME%%lianjian%%miaoshu%%lianjian%%ip%%lianjian%%mark%%lianjian%%gateway%%lianjian%%mac% >>%cn%
goto _end
:_end
exit