473,796 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Close Explorer windows

10 New Member
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 6331
ginge6000
10 New Member
Anybody able to help?
Mar 20 '08 #2
Stewart Ross
2,545 Recognized Expert Moderator Specialist
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
ginge6000
10 New Member
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 Recognized Expert Specialist
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\syste m32\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
1978
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 LANGUAGE="JavaScript">
10
38020
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 window? I have to click yes to close the window. How can I close the current window directly without this dialog box? Thank you.
4
4830
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 not ... can anybody tell me what I am doing wrong? Many thanks, Ronny Sigo Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
2
13243
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 prefer something a little less drastic. I suspect what I'm going to need is some API call such as SendMessage. Anybody have any suggestions?
2
1901
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 three buttons on a windows form that provide three options for the user the process goes like this user clicks button one and a web service is called that dwnloads a list
1
9239
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 programmatically to the directory and found that the easiest way to refresh the folder is to just open windows explorer. Without doing this, it isn't refreshed in the system. I had the same problem in VB6 and VBA as with VB.net. Searching the newsgroups...
37
6355
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, without getting a alert message that ask if u want to close the window. This did NOT happen in Internet Explorer 6, Mozilla firefox or other browsers.
7
5830
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 to be two techniques for earlier versions. But the window.opener='' ;window.close(); and the window.open('','_parent','') ;window.close(); techniques do not work for me. I.e., I still get confirmation message
2
8899
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 used this line to open the Windows Explorer Application.FollowHyperlink strPathName, , False, False How do I close Windows Explorer?
0
9673
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10449
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
10168
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
9047
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, and deployment—without 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
7546
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
5440
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...
1
4114
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
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
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.