Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    New York, New York, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Batch Files (XP 1)

    With Win XP, I am using DOS Batch files (does anyone remember them?) to backup selected files. The batch file consists of one stm, xcopy c:foldernamefilename E:, where E: is my CD write drive. That works fine, the only problem is that the DOS window opens, the batch file executes, and then the DOS window closes so quickly I can't read any messages. In Win 98, the property sheet for the batch file contained a check box that said "Close when finished", and if I did not click that, the window stayed open. That check box is missing in Win XP. Is there any way to keep the window open?

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    I'd opt for the simple solution....add a PAUSE statement as the last line. Oh yeah, I remember batch files. Believe me, they're alive and well at my company!!
    -Mark

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Location
    New York, New York, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    I had completely forgotten about the PAUSE statement. Thanks a lot.

  4. #4
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch Files (XP 1)

    And, since it's been mentioned many times here in The Lounge, if you want an alternative for the job of backing up selected files, check out Karen Kenworthy's <img src=/S/free.gif border=0 alt=free width=30 height=15> file replicator.

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    Hey, you're welcome....I told you they were alive and well!!
    -Mark

  6. #6
    Silver Lounger
    Join Date
    Apr 2001
    Location
    New York, New York, USA
    Posts
    2,328
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch Files (XP 1)

    There is another way: start your BAT file from Command Prompt (Start | Run, type CMD and hit Enter) like you did in good old DOS. All messages will remain in the window until you close it.

  7. #7
    New Lounger
    Join Date
    Apr 2002
    Location
    NSW - Australia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    just for interest, what is the difference between Start|Run|CMD and Start|Run|Command?
    you seem to get a different $P$G what else?

    Gary

  8. #8
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    The COMMAND prompt is in fact a 16-bit prompt andfollows a slightly different set of rules when processing commands. CMD is a 32-bit program not unlike many other programs that are designed to run under the Windows NT family of operating systems (of which XP is borne). The differences are mostly transparent but affect the way DOS based programs run. Most notably, the way memory is handled is different, but again, the differences are likely not to be noticed by a user, although some programs most certainly care!
    -Mark

  9. #9
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch Files (XP 1)

    Mark, help me out here with remembering the name: The thing I like about using CMD, Gary, is that the "DOS" window you get already has the old program for recalling commands loaded. Jeez, I can't remember it's name even. But if you use, for starters, the UP arrow key, you can recall commands and/or edit them. As you can tell, that's the only thing I ever use it for, but there's also macros and stuff there too. CMD is GOOD!

    [Edited FIVE mins. later!]

    DOSKEY says I, but it just takes my old brain a few minutes longer than it used to! Sorry

  10. #10
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    If you like the built-in DOSKEY functionality of CMD.EXE, here's a few others you might like.

    You can enable Automatic Completion of file & folder names, if you use start CMD with the /F parameter (ie. CMD /F). With this on you can type a command and part of a file name, then press CTRL-F to fill in the rest. Repeated CTRL-Fs cycle through available matches (within the current folder). If you don't enter any characters to match, all names are cycled. To limit the auto complete to folders, you can use CTRL-D (could it be a 'D" because folders used to be directories in the bad old days before politically correct Winspeak started to creep in?). You can make auto complete permanent for your PC, or on a per user basis, see KB 310530. (I haven't bothered with this step, partly because the instructions for file & folder name completion seem to be a... about face.)

    The Windows file associations are also supported. For example, if you type test.txt at the command prompt, the file is opened by Notepad, in a new window. Handy occasionally, especially with auto completion.

    QuickEdit Mode allows you to mark, copy & paste text with the mouse, instead of the Edit menu. Not always useful in a command line environment where your fingers are hovering over the keyboard, but it has its moments. You can toggle QuickEdit in the properties for the window, the official method is in KB 282301.

    Many of the old DOS commands & programs have become seriously more useful with each reincarnation of Windows. To dig deeper/wider, the Help command lists some commands you can get more help for (a subset deemed safe by Bill?). You can usually get help for unlisted commands (eg NET) if you use a "HELP", "/?", or "/HELP" command line parameter. I don't know if there's a list of these hidden commands floating around somewhere.

    It's almost a pity that batch files are hardly needed, now that all this functionality is available.
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  11. #11
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    I've only recently switched from W98 to XP, and was using COMMAND via the run box, until a few days ago, when I accidentally clicked the Command Prompt shortcut in Accessories. I found it sufficiently different from COMMAND, to find out what was behind it, and discovered CMD (better late than never)!

    Now I slap myself on the wrist if my fingers start typing "command", before correcting it to "cmd".

    As you say, most of the differences between COMMAND and CMD are subtle, but curiosity got the better of me, and I fiddled around with both to see for myself. What I found is probably mainly of curiosity value, but here 'tis anyway:

    COMMAND.COM, is a DOS program run under Windows. If started from the Run box, the window title is "C:WINDOWSSystem32command.com", but double-click the file directly and the title is "MS-DOS Prompt". Either way, if you run multiple instances (and group your taskbar buttons), they get lumped together as "NTVDM.EXE" (for, NT Virtual DOS Machine, maybe?). That probably explains why it's so much slower than CMD, especially to start and end. Inside the program window, COMMAND uses short file names in the command prompt and identifies itself as:

    Microsoft® Windows DOS
    ©Copyright Microsoft Corp 1990-2001.

    Ignoring short/long file name differences, and cosmetic upper/lowercase differences in the names, the following environment variables differ from CMD:

    COMSPEC=C:WINDOWSSYSTEM32COMMAND.COM
    TEMP=C:WINDOWSTEMP
    TMP=C:WINDOWSTEMP
    BLASTER=A220 I5 D1 P330 T3

    CMD.EXE is, as you say, a genuine Windows program, with a superset of COMMAND.COM functionality. If started from the Run box, the window title is "C:WINDOWSSystem32cmd.exe", as it is if you double-click the file. The default shortcut, under Accessories, sets the title to "Command Prompt". In any case, Multiple instances get lumped together as "Windows Command Processor". Inside the program window, CMD uses long file names in the command prompt and identifies itself as:

    Microsoft Windows XP [Version 5.1.2600]
    © Copyright 1985-2001 Microsoft Corp.

    The following environment variables differ from COMMAND:

    ComSpec=C:WINDOWSsystem32cmd.exe
    TEMP=COCUME~1useridLOCALS~1Temp
    TMP=COCUME~1useridLOCALS~1Temp
    windir=C:WINDOWS

    I suspect the difference in the TEMP/TMP values has the potential to cause some sloppy programs to throw a wobbly. The default command buffer doesn't seem to work for COMMAND, and it is noticeably slower than CMD. After all that, the only reason I can think of for the continued existence of COMMAND is that it may be needed for backward compatibility for some DOS programs.

    A final curiousity: The "DOS" copyright is only from 1990, while "XP" goes all the way back to 1985? That little gleam in Bill's eye must have been there for quite a while!
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  12. #12
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    I think Bill's gleam has been there all along, copyright dates be damned! <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    I believe the differences in the TEMP directory settings are due to the implementation of roaming profiles in 2000 and XP. That's what the Local Settings under Documents and Settings is for. If you run COMMAND.COM, since it's not NT-aware in the way CMD is, it doesn't play by the "roaming profiles" rules. Just a guess there. You can set runtime parameters for CMD va the autoexec.nt and config.nt files located in the System32 directory (folder, whatever). Your guess about NTVDM was correct....the NT Virtual Dos Machine.

    You can also use keyboard shortcuts in CMD that you can't in COMMAND. For example, left arrow key in CMD doesn't delete typed characters, but it will in COMMAND. CTRL+Left and Right arrow keys will take you from command to command (much like ion Word) and doesn't work in COMMAND. Most importantly, CMD is also the Windows XP (or 2000 or NT) command line interpreter, and understands more instructions, because it isn't bound to 8.3 limitations as demonstrated by the short filenames it displays. That's a 16-bit limitation at its finest. COMMAND is the MS-DOS interpreter, and the difference between is XP and DOS is, well, duh! Very noticeable.

    If you're curious, you can also type CMD /? at the run prompt and get extensive online documentation, with some runtime switches. And a final difference between the two interpreters that you may not have noticed.....if you click on the 'X' in the right hand corner of the window, CMD will simply exit whilst COMMAND will invoke a "Windows cannot end this task" box. If you're curious, you can also type CMD /? at the run prompt and get extensive online documentation, with some runtime switches. The difference in options is striking. When I compared I noticed a command switch that would have solved the problem that started this thread: CMD /K would have executed the command and left the window open.

    I thought I'd pass along a few tips for your arsenal regarding the CMD windows. I make frequent use of the F7 key, which will pop up a list of the commands in the buffer (anything you've entered). You can also increase the command buffer by modifying the PIF for your batch files (the icon properties). F2 will allow you to copy a line up to a certain character, and F4 will delete in the same manner. So, if you have a loooooong command line, you can delete up to say, character 15. Handy if you have a console only with no mouse.

    Cheers!
    -Mark

  13. #13
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    Thanks for the icing on the cake, Mark. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    <img src=/S/fanfare.gif border=0 alt=fanfare width=31 height=23> The COMMAND line is dead <img src=/S/sad.gif border=0 alt=sad width=15 height=15> Long live the CMD line! <img src=/S/fanfare.gif border=0 alt=fanfare width=31 height=23> <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  14. #14
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch Files (XP 1)

    It's like deja vu all over again, as Yogi would say, that you guys added to this thread when you did. I've been trying to find an answer to this since yesterday. I was doing some work in the CMD window and wanted to copy some text from the screen to the "clipboard." I was certain that could be done, but can't remember. Seems I even remember it's called "MARK.' Do either of you know where the answer is. I've looked in DOSKEY help.

  15. #15
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files (XP 1)

    You were so close that a mild expletive could be excused. There's two ways, keyboard & mouse:
    1. <LI>ALT-SPACE, Edit, Mark - then arrow around to what you want to copy. Hold down SHIFT and arrow around again to highlight the block you want to copy. Press ENTER, and it's on the clipboard. To paste it back in a CMD window use ALT-SPACE, Edit, Paste. Other apps is standard windows stuff.
      <LI>Mouse around to what you want to copy. Hold down the left button and drag around to highlight the block you want to copy. Right click, and it's on the clipboard. To paste it back in a CMD window right click again. Other apps is standard win stuff.
    For #2 you need QuickEdit Mode enabled, see my <post#=210683>post 210683</post#>, above.
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •