"Mark Tolonen" <[email protected]> wrote

Does this do what you want? It creates a new cmd window titled "Dir", then executes some commands.

import os
os.system('start cmd /c title Dir ^&^& dir ^&^& pause')

It didn't do quite what I expected, but it made me look at the
help for start, which says:

===================
Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
     [/WAIT] [/B] [command/program]
     [parameters]

   "title"     Title to display in  window title bar.
   path        Starting directory
=====================

So it looks like simply running start and specifying a title string
before the command should do the trick:

os.system('start "my window" cmd.exe')

Note the title MUST be in double quotes so the string to system must
either be rw or use single quotes.

You learn somethhing new...


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/





If you want the window to stay open after executing
the commands, use /k instead of /c. 'cmd /?' gives other switches you might want. The escaping(^) of the ampersands(&) is required or the commands will run in the current console not the new one.

import os
os.system('start cmd /c title Dir ^&^& dir ^&^& pause')

-Mark


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor



_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to