473,396 Members | 2,011 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.

Close Explorer windows

Hi,

I have an app which creates batch files to transfer stuff around a network. As part of the batch files they disconnect the networked M:\ drive. Unfortunately if a WIndows Explorer/My Computer window is open showing the M:\ drive then the batch file bombs out (can't disconnect network drive while in use) and the VBA gets stuck in an endless loop waiting for the batch file to announce that it has finished.

How can I check if any Windows Explorer/My Computer windows are open when the app first opens and then close them automatically?

Cheers for your help.

Ben
Mar 19 '08 #1
4 6188
Anybody able to help?
Mar 20 '08 #2
Stewart Ross
2,545 Expert Mod 2GB
Anybody able to help?
Sorry, ginge6000, this isn't really an Access issue at all, and the lack of response simply means that our contributors are not able to assist you with this one. We all check unanswered questions regularly and try our best to help if we have any useful suggestion to make.

In your very particular circumstances you would probably need to use a windows API function to do what you ask. All I can suggest is that you check the Microsoft Knowledgebase for something like the FindWindow API call and see if you may be able to wrap this in VBA. Once you find the window you would need to close it - again another API call. Can't think of anything else you could do, really.

-Stewart
Mar 20 '08 #3
Sorry, I thought it was an Access issue as I am trying to do it in Access VBA. Ah well, back to google I go........
Mar 20 '08 #4
FishVal
2,653 Expert 2GB
Hi, there.

You may use the following code though I couldn't prove it to be robust.
You have to reference "Microsoft Shell Controls and Automation" library (\WINDOWS\system32\SHELL32.dll).

Expand|Select|Wrap|Line Numbers
  1. Public Sub CloseMyComputer()
  2.  
  3.     Dim objShell As New Shell32.Shell
  4.  
  5.     For Each w In objShell.Windows
  6.         If w.LocationName = "My Computer" Then w.Quit
  7.     Next
  8.  
  9.     Set objShell = Nothing
  10.  
  11. End Sub
  12.  
Regards,
Fish
Mar 20 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Asit | last post by:
<META HTTP-EQUIV="expires" content="0"> <META HTTP-EQUIV="pragma" content="no-cache"> <html> <head> <title>Fidelity NetBenefits</title> </head> <body BGCOLOR="#ffffff"> <script...
10
by: Shang Wenbin | last post by:
Hi, When I want to close the current window using window.close() in IE6.0, there will be a confirm box that: The web page you are viewing is trying to close the window. Do you want to close this...
4
by: Ronny Sigo | last post by:
Hello all, Below is a testroutine. I am trying to open and cclose iexplore programmatically (the default startpage is suffcient, no need to specify another) The opening works, but the closing does...
2
by: Paul Steele | last post by:
Is there any way to check for open Explorer windows and if any are found, tell Windows Explorer to close them. I don't want a brute force method of killing Explorer and letting it restart. I'd...
2
by: Bruce Wiebe | last post by:
hi all im having a problem accessing a text file on my hard disk after ive created it and added some text to it it would appear that the file is still locked. What happens is this i have...
1
by: Mike Kober | last post by:
I'm having difficulty getting this to work. Any help would be appreciated. What I'm trying to do is to open Explorer onto the Windows/fonts directory and then close it. I've added a font...
37
by: Jan Tovgaard | last post by:
Hey everyone:) We have a critical problem, which I can see that other people also has ran into. In Internet Explorer 7 it is no longer possible to do a window.close after opening a window,...
7
by: Toccoa | last post by:
After considerable googling - I mean searching with Google(r) - I could not find javascript on a button or <a href=... to close a window in the latest versions of IE and FireFox. There seemed...
2
by: jercha | last post by:
I have a form that allows users to open Windows Explorer and view folders based on a list of path names. I want to create code that will close all or a specific Windows Explorer screen. I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.