Click to See Complete Forum and Search --> : How to I get a batch file window to close
Bellbus
08-22-2007, 06:36 AM
I'm having trouble with Sage - the Queue.dta file is becoming locked every time i close sage. No big deal, the solution is to delete the Queue.dta file.
To do this Ive created a text batch file to use instead of my Sage icon.
It looks like this:
del C:\SageV11\accdata\queue.dta
C:\SageV11\Sage.exe
exit /b
The problem is that due to Sage becoming the main window the Exit command is not running and I'm left with the Command Prompt window left open.
Can anyone tell me how to close the Window. I've created a shortcut to the Batch file which allows me to run it minimised, but I cant find a way to close it on finishing the script
use the call statement to run sage. then when its done the batch continues.
Bellbus
08-22-2007, 11:44 AM
Hi thanks,
My Bro' (University Admin) suggested 2 answers, that he reckons works on his machine, but neither have worked on mine (both on XP Pro with SP2).
The window just seems to stay open.
Echo "Sage Batch File"
DEL "C:\SageV8\accdata\queue.dta" /q /f
Call "C:\SageV8\Sage.exe"
EXIT
Echo "Sage Batch File"
DEL "C:\SageV8\accdata\queue.dta" /q /f
@"C:\SageV8\Sage.exe"
EXIT
He also suggested calling the batch file and adding cmd /c mybatch.bat, which should force the command prompt closed after running the script.
I have noticed the batch file closes after Sage is closed.
At the moment the best answer I have is to call it from a shortcut, set it to run minimised, and wait for it close after Sage is exited. This unfortunately leaves a taskbar icon at the bottom, but its better than nothing.
jjinno
08-24-2007, 05:05 AM
There is always the funky mess of testing error codes on completion of an execution... of course that is untested by me, but I hear that you can:
if errorlevel 26 echo Houston, we have an exit code.
or something like that
Try doing some Googling for the words trap, exit, signal, dos... maybe you will get further
Bellbus
08-24-2007, 05:11 AM
Hi thanks,
My Bro got bored and created a Visual Basic (vbs) script to do it instead.
You can run these instead of .bat files.
1. Copy the below code into notepad and save is as myfile.vbs
2. Change the FileToDelete at top to the correct file you want to delete
3. Change the ProgramToRun at top to the correct exe file
'
==================
Dim FileToDelete, ProgramToRun
FileToDelete="C:\Sagev11\accdata\queue.dta"
ProgramToRun="C:\Sagev11\sage.exe"
' Delete the file
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(FileToDelete) then
Set fs = fso.GetFile(FileToDelete)
fs.Delete
end if
' Call the program
Set WSHShell = WScript.CreateObject("WScript.Shell")
if fso.FileExists(ProgramToRun) then
WSHShell.Run chr(34)+ProgramToRun+chr(34), 1, false end if
' Free up memory
Set fso = Nothing
Set fs = Nothing
Set WSHShell = Nothing
WScript.Quit(0)
SysOpt.com
Copyright Internet.com Inc. All Rights Reserved.