473,847 Members | 1,709 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 5537
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
17742
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 simply executes and returns success, even when the bcp command fails. Has anyone run into this...
6
8541
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 shows up, they save the file and the window remains open. I've tried a number of things to get...
1
15200
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 verify that the batch file is functioning properly and then close the window myself. Am I missing a...
4
47557
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 line
1
1816
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
7600
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 the problem was to have the looping function execute as its own thread, the idea being this would...
7
1832
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
13395
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 -f /var/log/messages
4
2519
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
6557
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 Console.ReadLine() statement.
0
9730
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10338
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7882
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5719
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4528
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
2
4119
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3164
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.