
怎么讓BAT在不同版本系統運行自己電腦開發的CMD 比如寫 ipco
nfig /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 hkcucontrol paneldesktop /v wallpaper /d %cd%/test.jpg /f
- reg add hkcucontrol paneldesktop /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 hkcucontrol paneldesktop /v wallpaper /d %cd%/test.jpg /f
- reg add hkcucontrol paneldesktop /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
nclick="copycode($('code0'));">復制代碼
自學沒多久 現在困擾SET 參數 老是無效 只能> 到TXT然后讀取TXT的信息到 SET 參數