473,545 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5521
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.ba t" 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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQG4y64echKq OuFEgEQKgkACg0I y36W2SO/+tnf+OKCHtDzXET IQAoKJk
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******** ***********@new sread2.news.pas .earthlink.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.ba t" 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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQG4y64echKq OuFEgEQKgkACg0I y36W2SO/+tnf+OKCHtDzXET IQAoKJk
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*******@yaho o.com> wrote in message
news:78******** ************@ne ws01.bloor.is.n et.cable.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******** ***********@new sread2.news.pas .earthlink.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.ba t" 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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQG4y64echKq OuFEgEQKgkACg0I y36W2SO/+tnf+OKCHtDzXET IQAoKJk
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 @ stanleyassociat es . 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*******@yaho o.com> wrote in message
news:78******** ************@ne ws01.bloor.is.n et.cable.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******** ***********@new sread2.news.pas .earthlink.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.ba t" 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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQG4y64echKq OuFEgEQKgkACg0I y36W2SO/+tnf+OKCHtDzXET IQAoKJk
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
17704
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. For example, if the bcp command is improperly formatted, or has a bad password, I want the batch file to return an error. Right now, my batch file...
6
8509
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 all works fine. If the user selects "Open" or "Cancel", the window closes, which is the desired behavior. If they select "Save", the location dialog...
1
15176
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 Access, the Shell window becomes a blip on the screen and then is gone. Why does the Shell window not stay open on the screen? I want to visually...
4
47457
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) 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...
1
1804
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 name/title) and close it. Thanks,
8
7577
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 looping function the window becomes unmovable and cannot close under its own direction (the upper right "close 'X'") My first attempt to solve...
7
1819
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 is that there are as many dos windows as calls to "myProcess.start()", and I don't know how to do ... Anybody has an idea ?
4
13368
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 like is to get the output of the batch file to display on the gui as the batch file is running. if some of you understand unix... I want this: tail...
4
2497
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(); } </script>
12
6506
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 combination to hide the console window at launch time. The application (for legacy reasons) hangs around by waiting on an old- fashioned...
0
7490
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7682
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7449
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7780
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.