How to lock computer ( or say just keyboard ) locally or in the network via Java

Hi,

I'm workin' alone in makin' a software for a cybercafe which can lock other computers in the network via a software running in the main server. Like some other software do, I want to make it capable of lockin' computers in the network or when a user exit by pressing some button locally. And as I'm usin' Java language I'm wonderin' how's it possible via java. If anyone readin' this topic thinks that he/she can help me then plz help me soon.

regards,

Jay  :expressionless:

Well, I think you're on the wrong forum to be discussing this, but since you're here.



You're going to have to either make a JNI call or execute an executable that does it for you.  I think there is a simple exe file that you can download as part of the Windows tools set (don't remember the exact name…been a long time) that can be called to lock the box.



Personally I think you're better off with JNI as it's a more reliable solution and not dependent on some executable being able to be found when you want to execute it.



darkfrog

Thanks for ur suggestion but in JNI I have to make calls to the methods written in some other language via java isn't it (if i'm not wrong) but I don't have any knowledge 'bout other languages. So, isn't there any code written in pure Java for doin' so. I thought may be JDIC can help me but couldn't find any class for doin' so. So, isn't there any alternative for JNI?? :expressionless:

regards,

Jay

Well, the second option I mentioned would be a viable alternative and then there's always the off chance that you could use Jacob's COM bridge to pass a COM message telling the Windows box to lock, but that's is pre-supposing that Windows makes that available via a COM call.



Do a search on google for a exe for locking your machine, test it and make sure it works and then just do a Runtime.getRuntime().exec("myexec.exe"); and you should be on your way.



darkfrog

SWEET!  Just out of curiosity I just went and looked up the best way to do this and I thought this was pretty cool:



Runtime.getRuntime().exec("rundll32.exe user32.dll, LockWorkStation");



Add that line of code and you should be G2G.  Now that was a spoonfeeding, you could have easily looked that up yourself, don't expect such things in the future.  Particularly when you ask a question on the wrong forum in the first place. :-p



darkfrog

Thanks in advance for ur great help

wow… grt… Thanks again for now I used it n' saw it work… can u plz tell me where can i find such adorable commands… :slight_smile:

…google? :-p



darkfrog

-Thanks a lot…  :mrgreen:



regards,

Jay