Batch file closes program after executing command. How to stop this? - batch-file

I have a program that uses batch scripts internally since I do not have the newer software to that will allow me to create an exe to run inside the program. This is for my job, so I cannot purchase software and make it happen myself. So my work around with what I have is to create a batch file for a script that will run it automatically from within the program when clicking its icon. Problem is (50/50) when I run the .bat the command prompt opens and runs just fine then closes the command prompt after executing. Good. But then It also closes my program and I do not know how to prevent it from doing so. Is there something I need to add to the command prompt that will not close the program i am using the script in?
"C:\Program Files (x86)\JDA\Intactix\Space Automation\autopilot.exe" /play "C:\Users\Public\Documents\AAA SWB Custom\SCRIPTS\SWB - Desc 39 Survey Date.aps"
The autopilot.exe opens up Space Automation where scripts are written and played. The command prompt opens this program and runs the script then closes the program and the command prompt. But for some reason it also closes the program I am running it in.

ignore what i am saying and just copy the code lol kasdijkiojoipgo mipogaio goi juioj oiefj ioqj iojioqejoqeg oeiqwjc oij qoijfq oije oije fgiououimgqiou moi gq mqeo meqoio imo igoiqe eogeoqi jioqejgo joi moeigeqoi mgoi mohij rowt pokjpoq jpoerig iopw4i gmjwreo miomgwpj gioj
cd "C:\Program Files (x86)\JDA\Intactix\Space Automation\"
autopilot.exe /play "C:\Users\Public\Documents\AAA SWB Custom\SCRIPTS\SWB - Desc 39 Survey Date.aps"
or just
cd "C:\Program Files (x86)\JDA\Intactix\Space Automation\"
start autopilot.exe /play "C:\Users\Public\Documents\AAA SWB Custom\SCRIPTS\SWB - Desc 39 Survey Date.aps"
I hope i helped you.

Related

Winzip Self Extracting exe would end abruptly without showing "All Done" in cmd

I have got a batch script that ends with the following:
TITLE ALL DONE. You can close this window
ECHO.
ECHO ALL DONE. You can close this window
ECHO.
Pause
EXIT
it works fine when i run just the bat file (see below)
All Done! You can close this window.
Press any key to continue . . .
But when i create a self extracting exe out of the same bat script it wouldn't show this window after the execution and would just exit without any proper message.
Since the script works fine by itself, i am a bit lost on what could be causing this? How could i make the self extracting exe to show that window and prompt the user to close it like above.
It depends on the content of the executable, if your including other files to your archive be sure the program you run after extraction is your batch file.
If your only including that file i suggest you use BatToExe Converter
much more efficient way to build it, also it supports commandline, including other files, product info, admin manifest etc

Batch Files - Closing Opened Text Files

I currently have a Windows batch file that runs an .exe file that uses a text file. I am trying to have the Windows batch file run the .exe file multiple times. This, however, requires the use of the same text files to read from. The command prompt gives me the error that the ".txt could not be opened" (I assume from this that it is already open.)
I am trying to see if there is a way in a .bat file to system call to kill that specific text file. The suggestions I see online are to use 'taskkill notepad.exe', but that returns "invalid argument" because the program doesn't open Notepad to use the text file.
Any suggestions would be appreciated.
It sounds like your existing script fails because the first instance of the exe is still open when the second instance starts.
One thing worth trying (and this depends on the nature of the application you are invoking) is to start the executable using the START /WAIT /B ... command. This makes the command interpreter wait for the program to exit before it moves onto the next command, so as long as nothing else is locking the text files you should be OK to move onto the next command.

Closing cmd window after opening it with shellExecute()

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
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

how to execute cmd commands and compile it in a .bat file

Hello I'm getting sick from repeating commands in the cmd window so I want a .bat file that makes cmd opens then execute the command, and would be great if it's closed after executing the commands like example:
ipconfig/release
ipconfig/renew
Then closes the cmd window
Thanks.
Easy:
Put both commands in a text file, name it "new.bat".
Add a #echo off and a exit, and you are done:
#echo off
ipconfig/release
ipconfig/renew
exit
Every time, when you enter new, it will execute these commands.
And you can even do it with a double-click in WindowsExplorer.
You could save the .bat file to the desktop, so you can reach it easy with your mouse.

Batch file that doesnt run

I have creted a batch file that I want to run the SetupCodeGroup.exe
When I double click the batch file it doesnt run the exe file. A command prompt opens up but it doesnt run the file. Can someone tell what I missed or what I am missing
C:\Users\raw008\Desktop\Critcare\SetupCodeGroup.exe
type pause on the next line and check whether this executable comes on the command prompt .
try
start C:\Users\raw008\Desktop\Critcare\SetupCodeGroup‌​.exe
moreover
start /d "path_to_file_directory" program.exe
is the complete line to execute program and console will not wait to program to exit .
I wonder if this exe requires administrative privileges. Try right-clicking the batch file and running it as administrator.
#echo off
start C:\Users\raw008\Desktop\Critcare\SetupCodeGroup‌.exe
echo Done
pause
try that if that dose not work then your computers privleges are messed up, i ran into the same problem on my cousins computer.

Resources