Windows 10(64 位).bat 文件中 "msg" 命令的替代方法

Alternative for "msg" command in .bat file for Windows 10 (64 bit)

我写了一个小的计时器脚本作为 .bat 文件,它每 30 分钟(1800 秒)在弹出消息框中提醒我(16 次)"Move!"。该脚本在 Windows 7(32 位)系统上运行良好,但对于 64 位系统,"msg" 命令似乎无法使用或不存在。是否有任何替代此命令的方法或可以轻松替换该命令的方法?

set TIMER=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
set USERS=(%username%)
set MESSAGE=Move!

for %%i in %TIMER% do call :doit

:doit

for %%i in %USERS% do msg %%i %MESSAGE% 

timeout /t 1800 /nobreak
goto:eof

您可以创建一个临时 VBS 脚本,运行 然后将其删除。

See Example MessageBox

在您的程序底部包括:

exit /b
:msg
set tempPath=%temp%\msgbox.vbs
echo msgbox "%message%" > %tempPath% && %tempPath% && del %tempPath%
goto:eof

然后您可以像这样通过脚本使用它:

set message=Hello World
call:msg

所以在你的情况下:

set TIMER=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
set USERS=(%username%)
set MESSAGE=Move!

for %%i in %TIMER% do call :doit

:doit

set message=%MESSAGE%
call:msg

timeout /t 1800 /nobreak
goto:eof


exit /b
:msg
set tempPath=%temp%\msgbox.vbs
echo msgbox "%message%" > %tempPath% && %tempPath% && del %tempPath%
goto:eof