473,700 Members | 2,824 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 47518
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

2
1914
by: Jon Maz | last post by:
Hi All, To allow myself to make development changes directly on a remote server *without* having to compile on my local dev machine and then upload the dll's to remote, I have created a RunBatch.aspx on the remote which calls a batch file (myBuild.bat) on the same machine, and this batch file executes the necessary command-line compiler instructions to recompile (code below). So far (fingers crossed) it seems to be working. The only...
1
15190
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
5527
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
26
34576
by: mvdkwong | last post by:
What's the trick to running a batch file from VBA? I'm trying to call it using the Shell function but it's not working for me. If I double-click the batch file or run it from the command line it works. I've tried: RetVal = Shell("cmd /c clean.bat", vbNormalFocus) RetVal = Shell("clean.bat", vbNormalFocus) RetVal = Shell("<full path>clean.bat", vbNormalFocus) Call Shell...
7
21594
by: rhjaisingh | last post by:
Folks, I need to create a batch file that will do the following - Establish a DB2 instance Connect to a certain database Get data using an sql and output it to a file So, this is what I have done in my test.cmd file
4
13381
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
12
4094
by: Brett Romero | last post by:
I'd like to execute a batch file. However, I just get a quick DOS window flash when I run this code: System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo (@"C:\mybat.bat"); System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo = p; proc.Start(); proc.WaitForExit();
1
5272
by: byjufromgamut | last post by:
I created a batch file, when executes gives a preview window(using swings & JFrame). I created another java fie in which used a Process object and Runtime.getRuntime().exec(path) , where path specifies the location of above batch file. when indepedantly executes i am able to execute the bath file through this second program. Now the problem is that i want to execute the batch file in my JSP where i have tried a lot to execute the batch file...
29
2549
by: sukatoa | last post by:
Can a batch file executes the .COM file? Can i invoke it with java? I really have no experience on batch file.... can you give me some patterns or hint code? or if you can't, just the best URL you have known?!!! Any reply will be greatly appreciated, Sukatoa
0
8714
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8641
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
9203
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8958
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8912
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...
0
7797
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
3082
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
2379
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2021
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.