473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CMD window will not close after Batch file executes

I need help closing a CMD window when it is executed from Access.

1) The batch file is called from Access.
2) Access closes,
3) the batch runs a copy of the access database (creating a backup)
4) Once the copy is complete, the batch file opens the Access database
again
5) EXIT should close out the cmd window but it does not execute that
line

It appears that the batch file does not proceed any further than the
code:

"My Access DB.mdb"

ie.

echo off
cls
echo "Hit enter to backup"
pause
del ...
copy ...
ren ...
echo "done - Hit enter to open database"
pause
"My Access DB.mdb"
echo "This line will execute after My Access DB.mdb is closed"
pause
Exit

I use: Call Shell("cmd.exe /c " & tmpBatch, 1) to execute the shell.
I have tried many variations with identical results. If I remove the:
"My Access DB.mdb" line, then the cmd window completely executes and
closes. If I leave it in there, it will open the database as desired,
and will remain open UNTIL I close the access database. Once the DB
is closed, the batch file finishes executing the code after "My
Access DB.mdb". I do not want this window to remain open during this
period as the batch file needs to be deleted after the DB opens.

Any help would be appreciated.

Thanks
Nov 12 '05 #1
4 5505
Bill wrote:
I need help closing a CMD window when it is executed from Access.

1) The batch file is called from Access.
2) Access closes,
3) the batch runs a copy of the access database (creating a backup)
4) Once the copy is complete, the batch file opens the Access database
again
5) EXIT should close out the cmd window but it does not execute that
line

It appears that the batch file does not proceed any further than the
code:

"My Access DB.mdb"

ie.

echo off
cls
echo "Hit enter to backup"
pause
del ...
copy ...
ren ...
echo "done - Hit enter to open database"
pause
"My Access DB.mdb"
echo "This line will execute after My Access DB.mdb is closed"
pause
Exit

I use: Call Shell("cmd.exe /c " & tmpBatch, 1) to execute the shell.
I have tried many variations with identical results. If I remove the:
"My Access DB.mdb" line, then the cmd window completely executes and
closes. If I leave it in there, it will open the database as desired,
and will remain open UNTIL I close the access database. Once the DB
is closed, the batch file finishes executing the code after "My
Access DB.mdb". I do not want this window to remain open during this
period as the batch file needs to be deleted after the DB opens.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don't include the cmd.exe /c in the Shell() function. Just use the
batch file name. Invoking a batch file will automatically open the
Command window. If you're worried about the command window displaying
while the Access app is running: instead of a Shell WindowStyle of 1,
use 0 (zero) to hide the command window: Shell("batch.bat" 0).

In earlier versions of Windows you could edit the properties of a Batch
file to "close window on completion." This would cause the command
window to close when the batch file finished (whether or not "exit" was
the last command). I can't see that option in Windows XP. Ah,
progress....

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG4y64echKqOuFEgEQKgkACg0Iy36W2SO/+tnf+OKCHtDzXETIQAoKJk
hu4LP8gCvSngep/C2CYbTlVY
=gwTb
-----END PGP SIGNATURE-----

Nov 12 '05 #2
Using just the filename only without the cmd.exe was one of my various
options that I had tried with the identical result.
I also tried Command.com /c file.bat, I tried it without the /c and a few
other ways all with identical results.

I am on NT if that makes any difference.

Thanks...Any other suggestions?

Bill, aka Mr. "Can't close a cmd window"

"MGFoster" <me@privacy.com> wrote in message
news:Op*******************@newsread2.news.pas.eart hlink.net...
Bill wrote:
I need help closing a CMD window when it is executed from Access.

1) The batch file is called from Access.
2) Access closes,
3) the batch runs a copy of the access database (creating a backup)
4) Once the copy is complete, the batch file opens the Access database
again
5) EXIT should close out the cmd window but it does not execute that
line

It appears that the batch file does not proceed any further than the
code:

"My Access DB.mdb"

ie.

echo off
cls
echo "Hit enter to backup"
pause
del ...
copy ...
ren ...
echo "done - Hit enter to open database"
pause
"My Access DB.mdb"
echo "This line will execute after My Access DB.mdb is closed"
pause
Exit

I use: Call Shell("cmd.exe /c " & tmpBatch, 1) to execute the shell.
I have tried many variations with identical results. If I remove the:
"My Access DB.mdb" line, then the cmd window completely executes and
closes. If I leave it in there, it will open the database as desired,
and will remain open UNTIL I close the access database. Once the DB
is closed, the batch file finishes executing the code after "My
Access DB.mdb". I do not want this window to remain open during this
period as the batch file needs to be deleted after the DB opens.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don't include the cmd.exe /c in the Shell() function. Just use the
batch file name. Invoking a batch file will automatically open the
Command window. If you're worried about the command window displaying
while the Access app is running: instead of a Shell WindowStyle of 1,
use 0 (zero) to hide the command window: Shell("batch.bat" 0).

In earlier versions of Windows you could edit the properties of a Batch
file to "close window on completion." This would cause the command
window to close when the batch file finished (whether or not "exit" was
the last command). I can't see that option in Windows XP. Ah,
progress....

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG4y64echKqOuFEgEQKgkACg0Iy36W2SO/+tnf+OKCHtDzXETIQAoKJk
hu4LP8gCvSngep/C2CYbTlVY
=gwTb
-----END PGP SIGNATURE-----

Nov 12 '05 #3
Try calling Access asynchronously using the Start command, something like:

Start "My Access DB.mdb"

Also, you might put a CLS at the end of the batch file after any echo or
pause commands, so nothing is onscreen to view.

- Steve
"sixsoccer" <si*******@yahoo.com> wrote in message
news:78********************@news01.bloor.is.net.ca ble.rogers.com...
Using just the filename only without the cmd.exe was one of my various
options that I had tried with the identical result.
I also tried Command.com /c file.bat, I tried it without the /c and a few
other ways all with identical results.

I am on NT if that makes any difference.

Thanks...Any other suggestions?

Bill, aka Mr. "Can't close a cmd window"

"MGFoster" <me@privacy.com> wrote in message
news:Op*******************@newsread2.news.pas.eart hlink.net...
Bill wrote:
I need help closing a CMD window when it is executed from Access.

1) The batch file is called from Access.
2) Access closes,
3) the batch runs a copy of the access database (creating a backup)
4) Once the copy is complete, the batch file opens the Access database
again
5) EXIT should close out the cmd window but it does not execute that
line

It appears that the batch file does not proceed any further than the
code:

"My Access DB.mdb"

ie.

echo off
cls
echo "Hit enter to backup"
pause
del ...
copy ...
ren ...
echo "done - Hit enter to open database"
pause
"My Access DB.mdb"
echo "This line will execute after My Access DB.mdb is closed"
pause
Exit

I use: Call Shell("cmd.exe /c " & tmpBatch, 1) to execute the shell.
I have tried many variations with identical results. If I remove the:
"My Access DB.mdb" line, then the cmd window completely executes and
closes. If I leave it in there, it will open the database as desired,
and will remain open UNTIL I close the access database. Once the DB
is closed, the batch file finishes executing the code after "My
Access DB.mdb". I do not want this window to remain open during this
period as the batch file needs to be deleted after the DB opens.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don't include the cmd.exe /c in the Shell() function. Just use the
batch file name. Invoking a batch file will automatically open the
Command window. If you're worried about the command window displaying
while the Access app is running: instead of a Shell WindowStyle of 1,
use 0 (zero) to hide the command window: Shell("batch.bat" 0).

In earlier versions of Windows you could edit the properties of a Batch
file to "close window on completion." This would cause the command
window to close when the batch file finished (whether or not "exit" was
the last command). I can't see that option in Windows XP. Ah,
progress....

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG4y64echKqOuFEgEQKgkACg0Iy36W2SO/+tnf+OKCHtDzXETIQAoKJk
hu4LP8gCvSngep/C2CYbTlVY
=gwTb
-----END PGP SIGNATURE-----


Nov 12 '05 #4
Ike
i have had a similar problem. the solution depended upon the version
of windows i was using. try putting the path in the start command.

start c:"my db.mdb"

i know it sounds silly but it worked for me.

"Stephen K. Young" <s k y @ stanleyassociates . com> wrote in message news:<c4*************@ID-65843.news.uni-berlin.de>...
Try calling Access asynchronously using the Start command, something like:

Start "My Access DB.mdb"

Also, you might put a CLS at the end of the batch file after any echo or
pause commands, so nothing is onscreen to view.

- Steve
"sixsoccer" <si*******@yahoo.com> wrote in message
news:78********************@news01.bloor.is.net.ca ble.rogers.com...
Using just the filename only without the cmd.exe was one of my various
options that I had tried with the identical result.
I also tried Command.com /c file.bat, I tried it without the /c and a few
other ways all with identical results.

I am on NT if that makes any difference.

Thanks...Any other suggestions?

Bill, aka Mr. "Can't close a cmd window"

"MGFoster" <me@privacy.com> wrote in message
news:Op*******************@newsread2.news.pas.eart hlink.net...
Bill wrote:

> I need help closing a CMD window when it is executed from Access.
>
> 1) The batch file is called from Access.
> 2) Access closes,
> 3) the batch runs a copy of the access database (creating a backup)
> 4) Once the copy is complete, the batch file opens the Access database
> again
> 5) EXIT should close out the cmd window but it does not execute that
> line
>
> It appears that the batch file does not proceed any further than the
> code:
>
> "My Access DB.mdb"
>
> ie.
>
> echo off
> cls
> echo "Hit enter to backup"
> pause
> del ...
> copy ...
> ren ...
> echo "done - Hit enter to open database"
> pause
> "My Access DB.mdb"
> echo "This line will execute after My Access DB.mdb is closed"
> pause
> Exit
>
> I use: Call Shell("cmd.exe /c " & tmpBatch, 1) to execute the shell.
> I have tried many variations with identical results. If I remove the:
> "My Access DB.mdb" line, then the cmd window completely executes and
> closes. If I leave it in there, it will open the database as desired,
> and will remain open UNTIL I close the access database. Once the DB
> is closed, the batch file finishes executing the code after "My
> Access DB.mdb". I do not want this window to remain open during this
> period as the batch file needs to be deleted after the DB opens.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don't include the cmd.exe /c in the Shell() function. Just use the
batch file name. Invoking a batch file will automatically open the
Command window. If you're worried about the command window displaying
while the Access app is running: instead of a Shell WindowStyle of 1,
use 0 (zero) to hide the command window: Shell("batch.bat" 0).

In earlier versions of Windows you could edit the properties of a Batch
file to "close window on completion." This would cause the command
window to close when the batch file finished (whether or not "exit" was
the last command). I can't see that option in Windows XP. Ah,
progress....

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG4y64echKqOuFEgEQKgkACg0Iy36W2SO/+tnf+OKCHtDzXETIQAoKJk
hu4LP8gCvSngep/C2CYbTlVY
=gwTb
-----END PGP SIGNATURE-----


Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DBA | last post by:
I have a windows batch file that executes a SQL Server bcp command. I would like to obtain a return code if the bcp command fails. However, I cannot seem to find the return code (if any) for bcp....
6
by: chon | last post by:
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This...
1
by: Rob | last post by:
I'm running a batch file using the Shell function. When I manually launch the batch file, the window remains open, since I use the 'pause' statement. But when I launch the batch file within...
4
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup)...
1
by: George Cooper | last post by:
Can anyone help please. I need a small executable (either the VB code or the program itself will do) to run within a batch file to activate a running 3rd party DOS window (identified by the window...
8
by: Shamrokk | last post by:
My application has a loop that needs to run every 2 seconds or so. To acomplish this I used... "Thread.Sleep(2000);" When I run the program it runs fine. Once I press the button that starts the...
7
by: w.monthard | last post by:
Hi, here is my trouble: I need to call 2 différents processes in a same dos window, the first one is needed for the 2nd, and I have to pass several different arguments to the 2nd. My problem...
4
by: ed | last post by:
Hi all, I'm very new to vb (2nd day) and I need to create a small app that will replace my old batch file with a flashy gui. I had some experience with access 2.0 which helps ;) What I would...
4
by: badaczewski | last post by:
The following javascript appears on a popup window. <script language="javascript" type="text/javascript"> function InsertContact(value) { window.opener.CallBackContact(value); window.close();...
12
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.