Avatar of BFanguy
BFanguy
Flag for United States of America asked on

How to check if an Access Application (not Process) is open for a user on a 2008R2 remote desktop server in vbs

I have some code that i use to test if a "process" is running for a user on a 2008R2 Remote Desktop server:
Dim IsOpen As String
Dim Loopcnt As Integer
Dim MaxLoops As Integer
Dim shell
Dim oNetwork                'Network Access Object
Dim sUserName               'Login Name of User
Set oNetwork = CreateObject("Wscript.Network")
sUserName = oNetwork.UserName
IsOpen = "N"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'VMMFGWIN.EXE'")
For Each objProcess In colProcessList
      If objProcess.GetOwner(tUser, Domain) = 0 Then
         If tUser = sUserName Then
            IsOpen = "Y"
         End If
      End If
Next
If IsOpen = "Y" Then
   Set shell = CreateObject("WSCRIPT.SHELL")
   shell.Run """\\Ct01\root\Visual\Scripts\OpenWO.vbs"" """ & Me.Base_ID & """ " & Me.Lot_ID & " " & IsOpen, , False
Else
   MsgBox "Manufacturing Window must be open before you can open the Work Order"
End If
Set shell = Nothing

Open in new window


I need to test to see if a user has a Microsoft Access application open.  The above code can only tell me if the user has MSACCESS *32 open.  I need to know if they have a particular Microsoft application called "QUA20  Data Books" open.
Remember the user is on a Remote Desktop Server.  20-30 users may have the QUA20  Data Books application open on the "Terminal" Server.  I need to know if the current user has it open.

Any help would be greatly appreciated.
VB ScriptMicrosoft AccessWindows Server 2008VBA

Avatar of undefined
Last Comment
Seth Simmons

8/22/2022 - Mon
Dale Fye

I'm not a terminal server expert, but if each user has a userid on terminal server, then you would simply check in the folder where the application is installed for that user to see if there is file with the same name as your application and a ".laccdb" file extension.

Each user should still have their own version of the application front-end.
BFanguy

ASKER
thanks, but they all share the same accmdb file on the terminal server.  i.e. only one lock file for 20-30 users.
Dale Fye

They should not be sharing the same accdb front-end.  That is a recipe for file corruption.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
BFanguy

ASKER
Battled my way through the file corruption problems 6 months ago.  We have 4 2008R2 Remote desktop servers.  Had a file share for front end for all 4 remote desktop servers, tons of corruption problems (after moving to virtual servers and SAN - Note: Ran for 3 years with no corruption problems with physical remote desktop servers and 1 physical file server share.  

Removed all local tables to SQL Server and placed the front end on the local drives of the terminal servers - no corruption problems in 6 months. ~100 users  (20-30 per front end).
Jim Dettman (EE MVE)

I'm a little tied up at the moment, but the way you'd do this in VBA is to look at all the top level windows and grab the caption.

I'm sure you can do this in VB Scripting as well.

If you don't have another response by tomorrow, I'll see what I can dig up.

Jim.
ASKER CERTIFIED SOLUTION
Dale Fye

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
BFanguy

ASKER
interesting.  will investigate.  thanks.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Dale Fye

This is very simplistic, but could easily be incorporated into an application which would allow you to store computer names with users and lookup user information based on the computer name.

But I'm concerned that all the users may end up with the same computer name if it is being run from a server.
BFanguy

ASKER
I was hoping to be able to test to see if they have the access front end application open without having to open the access front end.  looking at appactivate.... something from vba or vbscript.  

Remember i need to be able to see if the current user has the application open (it may be opened by 20-30 other users) on the "Terminal Server", not that it is open by someone.
Dale Fye

Are you trying to prevent them from being able to open the application twice?

You might try something like an AppLauncher, which stores the names of the applications, the people that are authorized to use them, and make the user sign in with their WindowsID when the AppLauncher is launched.  You could then keep track of when they open the application and close it, and check to see whether they already have it open.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Jim Dettman (EE MVE)

What is your ultimate goal?

Preventing the user from opening an app twice, or finding out who's in the app so you can do maintenance?

Jim.
BFanguy

ASKER
I want to open a form in the access app (if it is open) from another access front end app.  i.e. in access app OPR10.accdb, i want to be able to open a form in access app QUA20.accdb, but i need to know if QUA20.accdb is already open for the user for security reasons.
Seth Simmons

I've requested that this question be closed as follows:

Accepted answer: 500 points for fyed's comment #a40830875

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.