Link to home
Start Free TrialLog in
Avatar of SimonUK
SimonUK

asked on

Batch file: running notepad and exiting

Hi all

Silly little thing I can't seem to get around.  I want to run the following batch file:

_________________
@echo off
ftp -i -n -s:c:\path\ftpscript.ftp
notepad.exe "c:\documents and settings\my name\my documents\file.txt"
exit
_________________

Basically the ftp script gets a text file and puts it in the right place, and notepad opens it.  Works great, except the batch window wont close until I've closed notepad.  I've tried "call notepad etc etc" but the same thing happens.
Is there a way I can force control back to the batch file so that it exits?

Thanks


Simon
ASKER CERTIFIED SOLUTION
Avatar of _corey_
_corey_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SimonUK
SimonUK

ASKER

OK.

I find that if you do:

explorer [path]

in a batch file, that works OK and the batch file exits.

So if I instead do:

@echo off
ftp -i -n -s:c:\path\ftpscript.ftp
explorer "c:\documents and settings\my name\my documents\file.txt"
exit

The explorer browser opens with the text in it - and the batch exits!

So how come that works and notepad doesn't?

Explorer must be spawning a process and existing.

corey
Avatar of SimonUK

ASKER

Thanks for your help.

Points awarded.

cheers


Simon
Yea, *exiting* sorry.  It might not make sense but there's no different in the batch file depending on the program you execute.

I was going to suggest writing a simple wrapper program that took the location of the executable and spawned it for you...but you can use explorer if you like.  Then just pass it the locate as you did above.

If you don't know any other languages, this would be more difficult.

corey
Simon,

  To be specifc, it looks like explorer is spawning a new thread for displaying that .txt file in an existing explorer process.  A similar concept, but the idea is that the executable that was called still exited and that's why the batch file continued.

corey
Avatar of SimonUK

ASKER

I don't really know any other programming languages (I've done a fair bit of VBScript but only thanks to experts here!).

In this case, it's not all that important - in fact the explorer solution is more elegant because it looks nicer!

I'd be interested though, if anyone does have a suggestion of how to achieve this.  I like using batch files for regular tasks so the more handy hints, the better !

In fact I'm about to post a new batch question about counting!

Simon