1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

batch files XP - ex 98se

Discussion in 'Windows XP' started by captjlddavis, 2004/09/14.

Thread Status:
Not open for further replies.
  1. 2004/09/14
    captjlddavis

    captjlddavis Well-Known Member Thread Starter

    Joined:
    2002/09/13
    Messages:
    588
    Likes Received:
    3
    New to XP - from 98se

    question regarding batch files:

    1. How the devil do you keep a batch file from closing when it finishes.

    I would like it to remain on screen for debugging...(used to be in pif properties)
    I know I can put a "pause" in it, but is there another way ?

    thanks for any assistance.

    regards:captjlddavis
     
  2. 2004/09/14
    surferdude2

    surferdude2 Inactive

    Joined:
    2004/07/04
    Messages:
    4,009
    Likes Received:
    23
    Batch files close by nature when they terminate. Whether the window they run in closes or not is a separate matter.

    In XP, if you run a batch file from the GUI, it will close the command window upon completion unless you insert the pause command in the script.

    To work around this limitation, run your batch files from a command window. That will retain the screen display after the batch closes.
     

  3. to hide this advert.

  4. 2004/09/14
    Newt

    Newt Inactive

    Joined:
    2002/01/07
    Messages:
    10,974
    Likes Received:
    2
    note: I posted this and noticed surferdude2 had beaten me to it but decided to just leave this as originally typed.

    Hmmmmm capt. Yes, no, sorta, but you most likely don't wanna, probably. :eek: :confused:

    :D

    With XP you are dealing with two completely different apps that can run a batch file or open a 'DOS' window, or similar.

    Cmd.exe is the newer one. A full 32bit app and in most cases, the one you would prefer to use.

    Command.com is a 16 bit version retained for backward compatibility for apps that simply demand a dumbed down command window.

    XP does not have DOS as you knew it with 95/98/ME.

    If you simply create a shortcut to a batch file or run it directly, you will be using the 32bit cmd.exe and as you noticed, it really likes to just exit when things are done.

    I have only found two ways with XP to force a batch file to run using command.com. There may be more elegant methods but if so, I don't know about them. Obviously you can do start -> run -> command.com and then run the file from the command line but if you want a shortcut:

    - Create a shortcut to c:\windows\system32\command.com. It should give you the red/yellow/black MS-DOS symbol for the icon.

    - Edit the .pif and change the command line from command.com to your batch file.

    There is a line in the 16bit PIF window for 'batch file' and according to help for that block, it should force command.com to execute the .bat file but I can't make that feature work so have just used the edit.
     
    Newt,
    #3
  5. 2004/09/14
    captjlddavis

    captjlddavis Well-Known Member Thread Starter

    Joined:
    2002/09/13
    Messages:
    588
    Likes Received:
    3
    Thanks to both.
    Newt:

    Looks like I will have to re-learn everything I thought I knew :mad:
    Got a ton of back-up batch files to do.

    Not a real happy camper, but so goes life.

    regards:captjlddavis
     
  6. 2004/09/14
    surferdude2

    surferdude2 Inactive

    Joined:
    2004/07/04
    Messages:
    4,009
    Likes Received:
    23
    captjlddavis, also be aware that some of the commands from Win9x batch files will not work in XP. For a complete rundown on the available XP commands, create a shortcut and paste the following code into the Command location window when asked:

    Code:
    %windir%\hh.exe ms-its:C:\WINDOWS\Help\ntcmds.chm::/ntcmds.htm
    Incidentally, when running batch files from the command window, you may need to set the screen buffer to a higher setting to allow you to see the entire script that has executed, especially if the batch has several lines. You can do that easily by editing the properties of the shortcut to the command window. On the Layout Tab presented, I keep mine set on width=90 and height = 460 since I run some very long batches. This allows me to scan through as many as 460 lines of it after it terminates. Without this change, you'll only get the default value of 25 lines.

    Good luck with your batch work.
     
  7. 2004/09/14
    captjlddavis

    captjlddavis Well-Known Member Thread Starter

    Joined:
    2002/09/13
    Messages:
    588
    Likes Received:
    3
    surferdude2,

    Thanks - gonna have to get a book I guess, nothing seems to work as it did -
    M$ did it again -

    regards:cptjlddavis
     
  8. 2004/09/15
    captjlddavis

    captjlddavis Well-Known Member Thread Starter

    Joined:
    2002/09/13
    Messages:
    588
    Likes Received:
    3
    Hello to all,

    I really appreciate the help.

    Fighting a losing battle with xp and batch files:

    Following batch runs as it shud from UI in 98se:

    file 1

    set profilepathe=c:\WINDOWS\Application Data\Moz_15b\Profiles
    set profilename= "jim_15b "
    set salted=uoas420a.slt
    set where= "e:\Moz_backup\ "
    set registry pathe=c:\WINDOWS\Application Data\moz_15b
    call BACKUP.BAT

    Modified for xp ????

    set profilepathe=C:\Documents and Settings\user\Application Data\Moz_17f\Profiles
    set profilename= "jim_1.7f "
    set salted=l2tqcfy0.slt
    set where= "e:\Moz_backup1\ "
    set registry pathe=C:\Documents and Settings\user\Application Data\Moz_17f
    pause
    call BACKUP.BAT


    File 2 (backup.bat)

    deltree /y "%profilepathe% "\%profilename%\%salted%\cache
    deltree /y "%profilepathe% "\%profilename%\%salted%\history.dat
    deltree /y "%profilepathe% "\%profilename%\%salted%\xul.mfl
    deltree /y "%profilepathe% "\%profilename%\%salted%\downloads.rdf
    ::deletes cache, history,download.rdf and xul.mfl before copying


    xcopy "%registry pathe%\registry.dat" %where%\registry.dat" /y /i
    xcopy "%profilepathe%\%profilename%\%salted%\" %where%\%profilename%\%salted%\ /s /q /h /e /y

    I added deltree.exe file to xp. so it works.
    Where am I going wrong with the backup.bat xcopy for xp ?

    Any additional assistance greatly appreciated.

    regards:captjlddavis
     
  9. 2004/09/15
    surferdude2

    surferdude2 Inactive

    Joined:
    2004/07/04
    Messages:
    4,009
    Likes Received:
    23
    Eliminate the third occurance of the " symbol from the line:

    xcopy "%registry pathe%\registry.dat" %where%\registry.dat" /y /i
     
  10. 2004/09/15
    surferdude2

    surferdude2 Inactive

    Joined:
    2004/07/04
    Messages:
    4,009
    Likes Received:
    23
    If that doesn't give you any relief, edit your set commands so that you enclose any path that has an embedded space with quotes. Then eliminate all other quotes that you have included on set paths without spaces in them. Then do not use quotes in the batch file when referring to the EV's you have set since they will be automatically included. I've found this method always works best.

    eg; set profilepathe=C:\Documents and Settings\user\Application Data\Moz_17f\Profiles

    becomes:

    set profilepathe= "C:\Documents and Settings\user\Application Data\Moz_17f\Profiles "

    and;

    set profilename= "jim_1.7f "

    becomes:

    set profilename=jim_1.7f

    etc.


    In the future you may want to use the RD command (remove directory) instead of the imported deltree command to accomplish the task. See the help files I previously referred to for all switches for that command.
     
    Last edited: 2004/09/15
  11. 2004/09/15
    captjlddavis

    captjlddavis Well-Known Member Thread Starter

    Joined:
    2002/09/13
    Messages:
    588
    Likes Received:
    3
    surferdude2,

    Thanks very much, I think that does it, just a couple more tweaks and it's done.

    regards:captjlddavis
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.