批处理文件中的 Vbscript 运行 不将击键发送到批处理文件

Vbscript ran from batch file not sending keystrokes to batch file

@echo off
timeout /t 2 >NUL 
cls
cd %temp%
set "var1=%random%%random%"
 echo >%var1%.vbs set shell = CreateObject("WScript.Shell"):shell.SendKeys "%{ENTER}" & %var1%.vbs
pause

这是我的代码。我基本上想要批处理文件做的是完全全屏打开自身(我说的是 f11 全屏模式)。您可以使用 ALT+ENTER 在 windows 10 上全屏显示批处理文件。所以我写了 vbs 发送键来做到这一点... %ENTER 是发送 ALT+ENTER... 当 运行 时,我没有收到 vbs 的错误...只是没有全屏...为什么?

我创建了这个批次并在我的 Windows 10 上测试了它,它有效 5/5


@echo off
Set "MyTitle=FullScreen"
Title %MyTitle% & color 0A & cls & cd %temp%
set "vbsfile=%~n0.vbs"
echo >"%vbsfile%" set shell = CreateObject("WScript.Shell"):shell.SendKeys "{F11}"
REM Timeout /t 1 /nobreak>NUL
Wscript.exe "%vbsfile%"
Ipconfig /all
pause

这是另一个批次,当你想全屏或回到正常屏幕时,可以使用它作为子调用:


@echo off
REM Here we call the sub :FullScreen to make it fullscreen
Call :FullScreen
Ping www.google.com
Tracert www.google.com
Call :FullScreen REM You come to the normal when we call it again the sub :FullScreen
ipconfig /all
Pause & Exit
REM -------------------------------------------------------------------------------
:FullScreen
Set "MyTitle=FullScreen"
Title %MyTitle% & color 0A & cls & cd %temp%
set "vbsfile=%~n0.vbs"
echo >"%vbsfile%" set shell = CreateObject("WScript.Shell"):shell.SendKeys "{F11}"
REM Timeout /t 1 /nobreak>NUL
Wscript.exe "%vbsfile%"
Exit /b
REM -------------------------------------------------------------------------------