Start Windows batch file maximized

root

I've written a batch file that I plan on distributing to a few dozen machines. It automatically checks the working state of several devices. I recently added a "menu" at the start of the script, prompting the user to select specific items to query from a list. The list, however, is too long to see without scrolling.

Rather than refining my list, what can I add to the batch to start the Windows shell maximized? I tried to cheat and Right click the .bat -> Properties -> Change the "Run" state to "Maximized", but this option does not exist (and frankly I'd rather add this feature within the script itself).

The machines that are running the script are running Windows 7

user2196728

You can try start /MAX yourscript.bat to start your script in a maximized cmd (up to Windows 7)

Edit (by Rik):

I've created a small example which shows how you could do it all in one batch-file
(without a separate launcher):

@echo off
if not "%1" == "max" start /MAX cmd /c %0 max & exit/b

:: here comes the rest of your batch-file
echo "test"

pause

There will be a slight flicker of the original batch-file (which will exit immediately) before starting the maximized version.


Simple explanation:
If the batch is not called with the parameter max we call itself again (%0), this time maximized with the help of start /max, and with the parameter max and that way the second time its called it will skip the if-statement and continue with your commands.

Breakdown:

  • if not "%1" == "max" execute the next command only if %1 is not "max". %1 stands for the first parameter given to the batch-file. So my_batch.bat max will have max in the %1-variable. If we didn't start the batch with a max parameter we need to execute this line.
  • start /MAX start the command after it, in maximized form.
  • cmd /c execute cmd.exe and /c means exit afterwards.
  • %0 max. The %0 stands for your own batch-file name and here max is its first parameter. This means we need to skip that first if-line or else we get caught in a loop :)
  • & exit/b: The & means execute the next command simultaneous with the previous. This means we executed the start /max your batchfile and in the meantime exit the current batch.

This also means we can't call this version with any other parameters than max. If your batch-files needs a parameter to start then you'll need to do some more magic (like shifting the %1 after testing).
If that's the case let us know.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Windows start command not able to execute batch file

From Dev

Windows batch file If/Else Start syntax?

From Dev

Open Windows Start Menu with a batch file?

From Dev

How to start an application Maximized using a .bat file?

From Dev

Windows batch file start another batch with elevated rights

From Dev

How to use regexp in windows batch file to start a installation?

From Dev

Windows CMD Start and wait for the default application in a batch file

From Dev

End a process started with START command in a Windows Batch File

From Dev

How to configure my system so that all windows start maximized?

From Dev

How to configure my system so that all windows start maximized?

From Dev

How to start gVim maximized?

From Dev

Start VLC maximized

From Dev

How to start a batch file minimized with task scheduler in Windows 8? - %comspec% method not working anymore after Windows 7

From Dev

windows service - start service using batch file using task scheduler on windows 2012 server R2

From Dev

"start" command in .bat batch file

From Dev

Batch file "start" command and parameters

From Dev

Start Excel file from Windows batch script in safemode, use default file association

From Dev

Windows curl Batch file

From Dev

Regex in a Windows Batch File

From Dev

Windows batch file browser

From Dev

Why does a program started by a batch file using command start not run while it runs via Windows Explorer?

From Dev

Why can't I start a batch file from a service using system() in Windows Server 2008?

From Dev

How to pin either a Shortcut or a Batch file to the new Windows 7, 8 and 10 Taskbar and start menu?

From Dev

When nested within if statement, start cmd not executing properly in windows batch file

From Dev

How to start Putty in a maximized window?

From Dev

How to start Putty in a maximized window?

From Dev

batch start path\this file's file name

From Dev

Maximized and minimized windows in windows 10

From Dev

Windows Batch start python script with pipe

Related Related

  1. 1

    Windows start command not able to execute batch file

  2. 2

    Windows batch file If/Else Start syntax?

  3. 3

    Open Windows Start Menu with a batch file?

  4. 4

    How to start an application Maximized using a .bat file?

  5. 5

    Windows batch file start another batch with elevated rights

  6. 6

    How to use regexp in windows batch file to start a installation?

  7. 7

    Windows CMD Start and wait for the default application in a batch file

  8. 8

    End a process started with START command in a Windows Batch File

  9. 9

    How to configure my system so that all windows start maximized?

  10. 10

    How to configure my system so that all windows start maximized?

  11. 11

    How to start gVim maximized?

  12. 12

    Start VLC maximized

  13. 13

    How to start a batch file minimized with task scheduler in Windows 8? - %comspec% method not working anymore after Windows 7

  14. 14

    windows service - start service using batch file using task scheduler on windows 2012 server R2

  15. 15

    "start" command in .bat batch file

  16. 16

    Batch file "start" command and parameters

  17. 17

    Start Excel file from Windows batch script in safemode, use default file association

  18. 18

    Windows curl Batch file

  19. 19

    Regex in a Windows Batch File

  20. 20

    Windows batch file browser

  21. 21

    Why does a program started by a batch file using command start not run while it runs via Windows Explorer?

  22. 22

    Why can't I start a batch file from a service using system() in Windows Server 2008?

  23. 23

    How to pin either a Shortcut or a Batch file to the new Windows 7, 8 and 10 Taskbar and start menu?

  24. 24

    When nested within if statement, start cmd not executing properly in windows batch file

  25. 25

    How to start Putty in a maximized window?

  26. 26

    How to start Putty in a maximized window?

  27. 27

    batch start path\this file's file name

  28. 28

    Maximized and minimized windows in windows 10

  29. 29

    Windows Batch start python script with pipe

HotTag

Archive