Question

CMD window does not return to it's original size after MODE command

Asked by: t0t0

I'm pulling my hair out over this one.

CMD's properties show:    Screen Buffer: w=80, h=300
                                           Window Size:   w=80, h=25

This is similar in appearance to a COMMAND window except it has a scrollable text background and therefore has a right-hand scrollbar.

In a batch file, MODE CON LINES=25 will set CMD's number of lines to 25 therefore, creating a 'scrolless' window and thus hiding the scrollbar.

CMD's properties now show:    Screen Buffer: w=80, h=25
                                                   Window Size:   w=80, h=25

Before exiting the batch file, MODE CON LINES=300 sets CMD's window's lines back to 300 thereby restoring it's scrollbar however, the Winow Size changes too.

CMD's properties show:    Screen Buffer: w=80, h=300
                                           Window Size:   w=80, h=40

1) Is there an explanation why this happens?
2) Can CMD's lines be restored to 300 without effecting it's Window_Size.Height setting?
3) Is there a registry-setting, or INI file-type solution?

Basically, I want to be able change CMD to a scrolless 25-lined window at the start of the batch file, and then restore it back to a scrollable 300-line window before exiting the batch file - BUT, without effecting the actual phyiscal size of the window itself (and certainly without effecting the Window_Size.Height setting). Can this be done?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-06-10 at 03:30:48ID24478802
Tags

CMD DOS Batch File MODE CON Lines= Window Size Height "Restore Setting" Scrollbar

Topic

MS DOS

Participating Experts
3
Points
499
Comments
19

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. scrollable container?
    I want to have a scrollable container in VB. Lets say I am having 40 text boxes to display in a SSTab control and my tab height is constrained by some other factors. So I need a scrollable container (similar to Java's scrollpane). How can I implement it in VB ?
  2. Cross Hair
    I am trying to create a profram that draws a straight line from 1 pt to another. I am having difficulty with creating a large cross hair marker , marking the end of line. Can any1 help ... plz :)

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: deroodePosted on 2009-06-10 at 04:07:21ID: 24589912

There doesn't seem to be a nice way to do this, there is however a kludgy way:

In your batch file:

mode con: lines=25
pause
start cmd.exe
exit

Effectively, this first sets the screen to 25 lines, then after the pause it opens a new cmd screen and shuts down the old. The disadvantage is that the new cmd box appears at a different place, and command history is lost.

 

by: QlemoPosted on 2009-06-10 at 06:43:24ID: 24591366

You can use cmdow (http://www.commandline.co.uk) to resize the cmd window from commandline. There is no direct way to revert the window settings, so this is the "smoothest" solution.

 

by: AbqBillPosted on 2009-06-10 at 08:10:34ID: 24592521

"Basically, I want to be able change CMD to a scrolless 25-lined window at the start of the batch file, and then restore it back to a scrollable 300-line window before exiting the batch file"

Why? Bill.

 

by: QlemoPosted on 2009-06-10 at 08:13:53ID: 24592575

That's something I asked myself several times reading this question ...

 

by: t0t0Posted on 2009-06-10 at 11:43:35ID: 24594719

Hiya guys.... First of all, thank you for your participation. Let me answer your question (Bill and Qlemo)...

I'm writing a series of batch files with embedded assembler routines (I know.... batch files.... embedded assembler. I've heard all the jokes). The embedded routines just means the user does not have to rely on external third-party commands. These batch files will run in a COMMAND box as well as a CMD box under XP. To ensure the display is consistent, I want to set CMD's window to the same size as COMMAND's window during execution then reset it to how the user had it prior to running the batch file (out of courtesy of course). I acknowledge some people will might run these batch file in a COMMAND box while others might run them in a CMD box. Basically, it's just a case of maintaining consistency.

That's why I don't want CMD's Window_Size to default to 40 lines when reseting CMD's Screen_Buffer.Height.

 

by: AbqBillPosted on 2009-06-10 at 12:23:41ID: 24595185

Hi t0t0, are these assembler programs MS-DOS programs? If so, this is likely why the screen is resizing itself. (I suspected this was the reason.) If you are running MS-DOS programs, be aware that such scripts will fail on 64-bit Windows. I recommend finding Win32 versions of what you need. Bill.

 

by: t0t0Posted on 2009-06-10 at 14:08:55ID: 24596532

Bill, that's great advice and something I did not take into consideration. The assembler routines consist mostly of standard DOS INT calls. Currently, I don't have access to a 64-bit PC.

 

by: QlemoPosted on 2009-06-10 at 17:29:56ID: 24597825

So my proposal would work. You know yourself how to read out the windows settings of the cmd box out of registry, I assume, and you can then reset the windows size to those values with cmdow.
Further I suppose you won't use
start /w command ASMprg.com > c:\output.txt
type c:\output.txt
to have the command window separated.

 

by: QlemoPosted on 2009-06-12 at 15:47:17ID: 24616823

BTW: 499 points? Is it 500 minus daylight saving?

 

by: t0t0Posted on 2009-06-12 at 16:56:55ID: 24617127

Qlemo
Hmmmm..... just wanted to break the mold.

I've struggled to keep up with EE lately as my PC has been down but I'm back now so I'll be looking at my replies in due course.

 

by: t0t0Posted on 2009-06-25 at 04:42:52ID: 24710305

Gentlemen

None of the comments are particularly helpful. I am however, exploring whether this behaviour is due to writing 16-bit code / 32-bit code instead of Win32 code.


abqBill

>> "are these assembler programs MS-DOS programs? If so, this is likely why the screen is resizing"
   FINDSTR.EXE is a DOS program but that doesn't effect the appearance of a DOS window

>> "be aware that such scripts will fail on 64-bit Windows"
   Good advice.

>> "I recommend finding Win32 versions"
   Still exploring whether Win32 code is the answer to this problem

Much Googling has not helped either. I have also bought no less than 6 (used) books on assembler - again, nothing mentioned there.

There are two issues here:

1) Why does only certain code (or COM and EXE programs) effect a DOS window
2) When the DOS window's LINES= setting is restored, why does it effect the size of the window

Strange, I'm about to pose this (2nd) question to MS and see if there is a work-around

 

by: QlemoPosted on 2009-06-25 at 07:51:14ID: 24711951

I agree nothing mentioned really solves the problem. And about the last sentence - ask them why they didn't allow for visual size and buffer size to be set independently.

 

by: t0t0Posted on 2009-06-25 at 08:12:07ID: 24712199

Actually, that's an interesting comment because, the two settings which you would think effect the window's appearance are:

   ScreenBufferSize.Height
   WindowSize.Height

and you would think using MODE CON LINES=300 would only affect the ScreenBufferSize.Height.

Let's face it, there's no way in a billion years XP is going to expand the window size to 300 lines so why expand it at all.

I requested a ScreenBufferSize.Heught of 300 bu XP epands the DOS winfow to 40,It doesn't make sense.

Furthermore, there's a separate setting for WindowsSize.Height - so setting the buffersize should not strictly affect the WindowSize.

It just doesn't make sense.

 

by: AbqBillPosted on 2009-06-25 at 08:34:47ID: 24712486

"FINDSTR.EXE is a DOS program but that doesn't effect the appearance of a DOS window"

No, findstr.exe is a Win32 console-mode program. It is not an MS-DOS program. There is a very large difference between the two.

HTH,

Bill

 

by: t0t0Posted on 2009-06-25 at 08:39:48ID: 24712558

Thank you for clarifying that AbqBill, that's the sort of reply that leads me closer and closer to arriving at a logical conclusion.

 

by: QlemoPosted on 2009-06-25 at 10:34:11ID: 24713902

I thought that was clear before. A 16bit program (pure DOS) does NOT have the typical Win32 EXE header "This program cannot be run in DOS mode". Command.com (as it is a .com) is an example for that, findstr for 32bit.

 

by: t0t0Posted on 2009-07-08 at 12:21:33ID: 24807217

Please do not reply to this as there is no need to...unless you can add something not already mentioned.

Okay, I accept 16-bit DOS applications running on a 32-bit machine is going to run under 'emulation' but this does not explain why the ODS box does not return to it's original physical size afterwards.

Nevertheless, we're almost there.

 

by: AbqBillPosted on 2009-07-08 at 13:59:17ID: 24808295

Hi t0t0, this is a side-effect of the MS-DOS emulation. There is no way, that I know about, to change this behavior, and AFAIK, Microsoft will not be addressing further DOS emulation problems (seeing as the DOS emulation no longer exists in 64-bit Windows). I would abandon the DOS program approach and use native Windows console utilities instead. Bill.

 

by: t0t0Posted on 2009-08-25 at 13:17:58ID: 31620396

Thank you for your patience.

I have re-written the code using 32-bit assembly. There are no DOS INT calls. These are replaced by Windows DOS API functions. This seems to solved the problem.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...