自己电脑开发的CMD 比如写 ipconfig /all 返回的全是英文。所以抓取关键字 获取IP以英文获取,但是 用到其他电脑上。返回的是中文显示。无法通用。
这种情况是不是只能用IF判断 对不同系统做适配?
有没有更方便的方法,比如设置回显变成英文 或者 设置cmd版本?
如果没有 那适配需要多少个版本?只需要适配英文中文 ?
因为个人开发个小应用 批量修改大量笔记本电脑的桌面壁纸 和 WIFI连接。- @echo off
- :: 设置窗体背景颜色
- color 1f
- :: 设置窗体标题
- title 正在监控http://192.168.1.46:5000
- echo 正在监控 http://192.168.1.46:5000
- set firstMatch=True
- ipconfig /all |findstr Physical>asdf.txt
- for /F "delims=" %%i in (asdf.txt) do (
- if defined firstMatch (
- set mac=%%i
- set "firstMatch="
- )
- )
- ipconfig |findstr IPv4>asdf.txt
- for /F "delims=" %%i in (asdf.txt) do (
- set ip=%%i
- set "firstMatch="
- )
- echo mac:%mac%
- echo ip:%ip%
- :next
- echo curl -s -d "mac=%mac:~-17%" -d "ip=%ip%" -X POST http://192.168.1.46:5000
- curl -s -d "mac=%mac:~-17%" -d "ip=%ip%" -X POST http://192.168.1.46:5000>asdf.txt
- set /p re=<asdf.txt
- del asdf.txt
- echo re:%re%
- if %re:~0,1%==0 (
- echo 在%date:~0,10% %time:~0,8% 访问正常
- echo 正在监控http://192.168.1.46:5000
- )
- if %re:~0,1%==1 (
- echo 在%date:~0,10% %time:~0,8% 访问正常
- echo %re:~1%
- echo http://192.168.1.46:5000/zhuomian/%re:~1%/%mac:~-17%/
- curl -o test.jpg http://192.168.1.46:5000/zhuomian/%re:~1%/%mac:~-17%/
- reg add "hkcu\control panel\desktop" /v wallpaper /d "%cd%/test.jpg" /f
- reg add "hkcu\control panel\desktop" /v WallpaperStyle /t REG_DWORD /d 2 /f
- RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
- set re=0
- )
- if %re:~0,1%==2 (
- echo 在%date:~0,10% %time:~0,8% 访问正常
- echo %re:~1%
- echo http://192.168.1.46:5000/wifi/%mac:~-17%/
- curl -o %re:~1%.xml http://192.168.1.46:5000/wifi/%mac:~-17%/%re:~1%/
- netsh wlan add profile filename="%re:~1%.xml"
- Netsh WLAN set profileparameter name="%re:~1%" connectionmode=auto
- netsh wlan connect name=%re:~1%
- set re=0
- )
- if %re:~0,1%==3 (
- echo 在%date:~0,10% %time:~0,8% 访问正常
- echo %re:~1%
- echo %re:*YY=%
- echo %re:~1%>123.txt
- set first=True
- for /f "delims=YY" %%i in (123.txt) do (
- if defined first (
- set reip=%%i
- set "first="
- )
- echo %reip%
- if "%reip%" NEQ "" (
- curl -o test.jpg http://192.168.1.46:5000/zhuomian/%reip%/%mac:~-17%/
- reg add "hkcu\control panel\desktop" /v wallpaper /d "%cd%/test.jpg" /f
- reg add "hkcu\control panel\desktop" /v WallpaperStyle /t REG_DWORD /d 2 /f
- RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
- )
- if "%re:*YY=%" NEQ "" (
- curl -o %re:~1%.xml http://192.168.1.46:5000/wifi/%mac:~-17%/%re:*YY=%/
- netsh wlan add profile filename="%re:*YY=%.xml"
- Netsh WLAN set profileparameter name="%re:*YY=%" connectionmode=auto
- netsh wlan connect name=%re:*YY=%
- )
- )
- )
-
- :: 休眠60秒
- choice /t 3 /d y /n >nul
- goto next
复制代码 自学没多久 现在困扰SET 参数 老是无效 只能> 到TXT然后读取TXT的信息到 SET 参数 |