[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 959
  • Last Modified:

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
0
SimonUK
Asked:
SimonUK
  • 4
  • 3
1 Solution
 
_corey_Commented:
No, call will simply return control back to the batch file after termination of the other program.

You will need to use a different language that allows process creation and execution that isn't blocking.

corey
0
 
SimonUKAuthor Commented:
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?

0
 
_corey_Commented:
Explorer must be spawning a process and existing.

corey
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SimonUKAuthor Commented:
Thanks for your help.

Points awarded.

cheers


Simon
0
 
_corey_Commented:
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
0
 
_corey_Commented:
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
0
 
SimonUKAuthor Commented:
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now