Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Batch file question

    Hello

    I'm a total novice with Win 2000, the last OS I got to grips with was DOS 6.x, since then I've just pointed and clicked, as that's met my needs. I now want to use a batch file to copy a programme from a server the local HDD (guarantee the latest version), and then launch the program. I've managed this, but the DOS window stays open, despite my putting the 'exit' command in as the last line. How do I close the DOS window when the file has finished running?

    And I believed Bill when he told us DOS was dead <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Thanks

    Ian

  2. #2
    Lounger
    Join Date
    Feb 2003
    Location
    Renfrewshire, Scotland
    Posts
    35
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Batch file question

    Create a shortcut to the executable, look at Program tab in properties and click 'close on exit'.

    Hope this fixes your problem

    DougieW

  3. #3
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch file question

    Dougie

    There is no program tab under the properties section for my shortcut. This may be because I'm running a .bat file with the short cut? not sure at all here.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Batch file question

    I think maybe the command window is waiting for the other program to send it a message, a message which never comes.

    I noticed in experimenting with shortcuts to .bat files that Windows creates a .lnk file rather than a .pif file. Not sure if there is a way around this; it is the .pif-type shortcut which has a Programs tab...

  5. #5
    Lounger
    Join Date
    Feb 2003
    Location
    Renfrewshire, Scotland
    Posts
    35
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Batch file question

    You're quite right, you only get the program tab if it's a shortcut to an .exe although I think you got that tab in w95/98. Possibly another MS step backward. If you look up the w2k help for PIFs you'll see that a shortcut to a dos .exe is a replacement for the PIF. Here's another couple of possibilities for you to try.
    1. If you can get your hands on an old PIF editor you could create a PIF and see if it runs under w2k (bleeding edge technology this!).
    2. Why do you have to copy the file to your HD? Assuming it is an .exe, run it from a shortcut pointing to the server copy (which should give you the program tab) and you wouldn't need the copy command as well or am I missing something?
    If neither of these work I'll do some more head scratching.

    Dougie

  6. #6
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch file question

    Dougie

    The 'programme' I'm running is an Access database. As the users are not particularly PC friendly I've had to replace the server copy twice already (they ctl alt del if it seems to have hung [busy network = slow database sometimes] and this can corrupt it). By having the front end on the local HDD the user will only corrupt the local copy (everyone else gets to keep working), by having the .bat file replace it each time they start up any corrupt local copy is replaced with a good server copy.

    I've been looking around for solutions, and have found references to .bat file compilers, these appear to turn the bat file into an .exe...... Have you any knowledge of this sort of programme? After all if it's an .exe I'll have the close programme tab on the short cut wont I????

    As I don't know squat about .pif files then getting my hands on an old .pif editor would just give me a new learning opportunity, but thanks for the suggestion.

    Thanks for your time and help so far.

    Ian

  7. #7
    Star Lounger
    Join Date
    Sep 2001
    Location
    Anchorage, Alaska, USA
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch file question

    Here's how I have created a "true" shortcut that allows the type of control you desire (i.e., getting the Program Tab so you can check Close on Exit) --- instead of creating the shortcut directly to the BAT file ... create a shortcut (eg., create New Shortcut with a right-click context sensitive click --- e.g. on the desktop), then fill out the Cmd line box on the Program tab.

    cmd.exe /c "FILE REVERENCE FOR YOUR BAT FILE"

    in which you replace the stuff in the quotes (leave the quotes in for long-filename &/or spaces in paths). Then you make sure you check the box on the Program tab that says Close on exit.

    Hope this helps.

  8. #8
    Lounger
    Join Date
    Feb 2003
    Location
    Renfrewshire, Scotland
    Posts
    35
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Batch file question

    Ian
    I've just seen Alan Bingham's suggestion and I'm sure that should do what you want but I've just looked at an old batch file of my own which had the same problem! Guess what fixed it - 2 exit commands! - 1 to stop the processing, 1 to close the window!

    edit added - I've just tried Alan's trick but it didn't work on my win2000 pro? - what OS do you have, Alan?
    Dougie

  9. #9
    Star Lounger
    Join Date
    Sep 2001
    Location
    Anchorage, Alaska, USA
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch file question

    Oops --- I do have Windows 2000 Professional as my OS, but it turns out I was using referring to a "pif" file instead of the usual "lnk" file (i.e., shortcut). Which I think I more-or-less inherited from moving files over from my older OS's ... originally Windows 95 ... then migrated to Windows NT ... and finally to 2000.

    Anyway --- it does work on Windows 2000 (at least on my machine) ... but it has to be a PIF file ... I've attached a relatively simple example to demonstrate ... the zip file has two files one called "today.bat" which has simply has the "DOS" set command (i.e. SET TODAY=200302121), which for the example to run needs to be in the root directory of your c: drive. The other file is "today.pif" which can be put anywhere --- it has the following "Cmd line" argument:

    cmd.exe /c "c:today.bat"

    with the Close on Exit checked.

    I suppose if the trick of using two exits on a batch file doesn't work, and a person wanted to use my approach instead ... they could just edit (by right-clicking and choosing Properties) the "today.pif" file included in the attached zip ... to point to their own batch file, rename it, point to a different icon, etc.

    Hope this helps.
    Attached Files Attached Files

Posting Permissions

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