Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I center batch files when they open up? I mean not by dragging but every time they open up they are automatically centered like is there a command? I am trying to make a game like that. And these are the game files I want to be centered. They're separate:

@echo off
type c1.txt
gotoxy 0 1
ping localhost -n 2 > Nul
start c2.bat
share|improve this question
What do you mean by "center batch files"? Do you want the window that execute the batch file to be centered on the screen? Or do you want some content inside the window to be centered? – dolmen Mar 27 '11 at 11:41

The easy way is simply modify the screen width of the Dos Box.

To set it up in a batch file:

mode con: cols=170 lines=50

FYI, I don't know how to "lock that. It will change the resolution during the Batch File run, however next time you open a command prompt, it reverts to the old settings. At least the batch File runs as you wish.

To determine best size for what your doing:

  • open cmd
  • Right click upper rail of CMD Window, choose Properties
  • Click "Layout" -Middle Choice=Window Size
  • Change that to
  • Width: 150
  • Height: 70

    • "Window Position: Check "Let System Position Window"

For your resolution, might be different (no clue how to make it user specific)

170x50 = Absolutely perfect window size for me. I can still see top url and bottom tabs, but takes up almost entire screen.

As an F.Y.I.

As I type this it's 2013, thus "Popular" is the Wide LCD/Short/Squat Height.

My Resolution is set at 1400x1050 It's rated "20-Inch" It's 21"-across/12"-tall (see, wide/squat)
(might make a difference, consider tweaking it)

share|improve this answer

You can do this with IE popups using VBS, but as far as I am aware that cannot be done to manipulate an existing command prompt. You may want to try using an AutoHotkey script within the batch file to do something like (A_ScreenWidth/2)-(Width/2), or use CenterWindow() in VC.

share|improve this answer

In the days of DOS, you used to be able to manipulate the screen output by loading up the ANSI.SYS driver and using ESCape sequences or by creating your text/images using an app like thedraw.

Checking for a modern solution for ANSI.SYS I came across ANSICON. With this app/utility installed, putting ANSI escape sequences in your txt file may work - I can't try it at the moment as I only have a Linux laptop at my disposal so feedback would be useful!

Edit: Thinking about things, I don't believe this will make centring text any easier as I cannot find an ANSI sequence that defines 'centre text' on a display - only for a printer - but this may be of use for designing screens so I will leave the answer here as it is.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .