1

Good Day.

I have an Powerbuilder application that triggers a batch file to start up a database server. Below the contents of the batch file:

"C:\Program Files\Sybase\SQL Anywhere 8\win32\dbsrv8.exe" -c 8m -n DEMO "C:\loadcon\db_demo\demo.db"

This all works fine. However I would like the command window to close automatically after the execution of the batch script. I have spend most of today reading this website and trying options that might work, like adding start, exit, /exit, /c but none work correct. With the start option in front it has a problem with the database switch -c. Repositioning the string quotation marks withing the batch file has undesirable effect on the database startup. However adding /exit at the end - first the the database promts a mssg 'Cant read file /exit' and then the cmd prompt closes - so, something is working but not 100%.

Anybody can enlighten me?

Thanks Alex

Matt Williamson
  • 6,947
  • 1
  • 23
  • 36

1 Answers1

0

You don't call it with /exit or /c

Batchfile.bat:

"C:\Program Files\Sybase\SQL Anywhere 8\win32\dbsrv8.exe" -c 8m -n DEMO "C:\loadcon\db_demo\demo.db"
EXIT 

It has to be a newline

edit

It might be that the program never actually exits, so will never reach the "EXIT" command. Usually when a .bat file is executed with windows scheduler or double-clicked, it will open and close the command prompt as soon as the program finishes and exists.

Might want to consider using vbscript or cscript to execute the command. I can't remember my vbs for batch files so well though :)

REEDIT 16 Apr

Re: your comment, try this?

cd C:\Program Files\Sybase\SQL Anywhere 8\win32
dbsrv8.exe -c 8m -y -q -n DEMO C:\loadcon\db_demo\demo.db
exit
user3036342
  • 1,023
  • 7
  • 15
  • Nope. Still staying open. Is there perhaps a windows function that grabs the shellexecute() handle to close it again ? – Alex Szlanina Apr 09 '14 at 14:39
  • Not as far as I know. It could be that the program you're running through the batch never exits properly itself which means the "EXIT" command in your .bat file will never fire – user3036342 Apr 14 '14 at 13:01
  • Funny. When I add the EXIT command straight after the last letter on the first line, i.e. ...\demo.db" EXIT, dbsrv8.exe complains that it doesn't understand file 'EXIT'. Anyhow, I will live with it for the time being. Main thing is the batch file executes correctly. The user can close it manually. – Alex Szlanina Apr 15 '14 at 16:03
  • I've edited my answer with an alternative. please try that? nb, it wont work if the dbsrv8.exe never exists itself – user3036342 Apr 16 '14 at 11:19
  • I added a -y to the command line, this forces it to operate without confirmation actions – user3036342 Apr 16 '14 at 11:28
  • also added -q for quiet mode so it doesn't print any messages to screen – user3036342 Apr 16 '14 at 11:29