@echo off&setlocal enabledelayedexpansion
color 2F
set "foundPath="
set "found="
if exist "D:\Ys\WeChatTools\Config.ini" (
for /f "tokens=1,2 delims=;" %%a in (D:\Ys\WeChatTools\Config.ini) do (
set "foundPath=%%a"
set "instanceCount=%%b"
)
echo 读取到配置中微信的路径:!foundPath!
echo 读取到默认多开微信数量:!instanceCount!开(直接回车将!instanceCount!开)
) else (
echo 配置文件不存在,将创建新文件...
if not exist "D:\Ys\WeChatTools" (
md D:\Ys\WeChatTools
)
echo.>"D:\Ys\WeChatTools\Config.ini"
set "instanceCount=1"
)
if not defined instanceCount (
set "instanceCount=1"
) else (
for /f "delims=0123456789" %%c in ("!instanceCount!") do (
if not "%%c"=="" set "instanceCount=1"
)
)
set /p "newInstanceCount=请输入要打开的微信数量:"
if not defined newInstanceCount (
set "newInstanceCount=!instanceCount!"
) else (
:: 验证用户输入的新数量是否为有效的数字,如果不是则设为 1
for /f "delims=0123456789" %%c in ("!newInstanceCount!") do (
if not "%%c"=="" set "newInstanceCount=1"
)
echo !foundPath!;!newInstanceCount!>"D:\Ys\WeChatTools\Config.ini"
echo 多开数量已更新为:!newInstanceCount!开
)
if defined foundPath (
if exist "!foundPath!\WeChat.exe" (
echo 找到:!foundPath!\WeChat.exe
set "found=1"
for /l %%k in (1,1,!newInstanceCount!) do (
start "" "!foundPath!\WeChat.exe"
)
goto :end
) else (
echo 配置的路径无效,正在搜索新的路径...
)
)
echo 搜索微信位置可能稍慢,搜到后会记录路径位置,
echo 以后再打开就快了,因为不用再搜索了,请稍等...
for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
if exist %%i:\ (
echo 正在搜索盘符 %%i:
for /f "delims=" %%j in ('where /r %%i:\ WeChat.exe 2^>nul') do (
echo 找到:%%j
set "found=1"
for /l %%k in (1,1,!newInstanceCount!) do (
start "" "%%j"
)
set "newPath=%%~dpj"
:: 比对新路径和原配置路径
if "!newPath!" neq "!foundPath!" (
echo 新路径与原配置路径不同,正在更新路径配置...
echo !newPath!;!newInstanceCount!>"D:\Ys\WeChatTools\Config.ini"
)
goto :end
)
) else (
echo 盘符 %%i: 不存在
)
)
:end
if not defined found (
echo 未找到微信WeChat的位置,请确定是否安装。
)
ping 127.0.0.1 -n 9 >nul
exit