Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check for username of running processes in vba

Status
Not open for further replies.

goddersb

Programmer
Mar 26, 2009
14
GB
Greetings,

I can manage, by either using enumerate windows or other functions, to check to see if an instance of Access is running and therby stop another instance loading. What i want though is to do this on a user by user basis. This because the accdr will be run on a remote server and i want to ensure that if User A logs on from one machine and opens Access, and does not shut down the accdr, when you go to start another session they will be told they need to close down the first one. So it is imperitive i only check for processes running for User A, otherwisr User B will be told that the application is running and they will need to close this - when in fact User A is the culprit.

Have looked and serached in may places thus far but have not found anywhere where i can find the solution, so does anybody have the answer?
 
tasklist /fi "username eq xxxxxxxx" > somefile.txt

you can get a list of processes running under the current user (replace "xxxxxxxx" with their network username) then search the resulting file for results.

John


 
Is that command line code you have suggested?
 
Using
tasklist /fi "username eq xxxxx" /fi "modules eq aceintl.dll" i can get what i am after, is there a better way than using the modules maybe?
 
I can generate an output from the command window using the above, but when i try in access using both Shell or Shell&wait no output is generated. Any ideas as to where i am going wrong?

Works in Cmd Line
tasklist /fi "username eq xxxxxx" /fi "modules eq aceintl.dll"> H:\Documents\chk.txt


Fails in VBA
mstrCmdLine = ""
mstrCmdLine = "tasklist /fi " & """" & "username eq xxxxx" & """" & " /fi " & """" & "modules eq aceintl.dll" & """"
mstrCmdLine = mstrCmdLine & "> H:\Documents\chk.txt"
mlngResult = Shell(mstrCmdLine, vbMinimizedNoFocus)
 
Replace this:
mstrCmdLine = ""
with this:
mstrCmdLine = "cmd /C "

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top