I have a few scripts to help running a program in CMD. The first script that starts the sequence is run on startup. In the process, I'm running a VBScript with which I'm trying to focus on the CMD and make it fullscreen. However, sometimes it works and sometimes it doesn't and I'm not changing anything, just restarting the computer over and over again. It doesn't always focus on the cmd window so the problem should be with the AppActivate
method.
Here is the code for the first script that runs on startup:
@echo off
TITLE masterBat
START "Master" /B /W myApp.bat
shutdown.exe /s /t 00
Here is the code for myApp.bat:
@echo off
cscript fullscreen.vbs
cd <path>
CMD /C <command>
exit
Here is the code for fullscreen.vbs
:
Set ws = WScript.CreateObject("WScript.Shell")
ws.AppActivate "masterBat - myApp.bat"
ws.SendKeys "{F11}"
Set ws = Nothing
The title in the AppActivate
call is the title on the cmd when I'm trying to make it fullscreen. I've also tried adding some WScript.Sleep
calls in the script but it doesn't seem to help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…