Link to home
Start Free TrialLog in
Avatar of BFanguy
BFanguyFlag 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.
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

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.
Avatar of 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.
They should not be sharing the same accdb front-end.  That is a recipe for file corruption.
Avatar of 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).
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
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BFanguy

ASKER

interesting.  will investigate.  thanks.
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.
Avatar of 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.
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.
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.
Avatar of 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.
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.