Thursday, November 14, 2013

Lock PC using Mobile Bluetooth

   This article describes a method of locking the PC when the user is not around.Actually it detects the user mobile phone's bluetooth (Obviously it has to be turned on all the time.) and if the application can't find the phone it sends a command to lock down the workstation.The codes are of JAVA and it uses the Bluecove library ,which is a open source one.The app uses the bluetooth mac address instead of the name so as to provide security.Hope this will help you.

  • To find the Bluetooth mac address :
package com.oksbwn.bluetooth;
import javax.bluetooth.*;
import javax.swing.JOptionPane;
public class BluetoothSearchAddress implements DiscoveryListener {
    private LocalDevice localDevice;
    private DiscoveryAgent agent;
   public BluetoothSearchAddress () throws BluetoothStateException {
        localDevice = LocalDevice.getLocalDevice();
        agent = localDevice.getDiscoveryAgent();
    public void inquiry() throws BluetoothStateException {
        agent.startInquiry(DiscoveryAgent.GIAC, this);
    public void deviceDiscovered(RemoteDevice device, DeviceClass devClass) {
        String devicesAndAdress="<html><body>";
        try {
        } catch (IOException ex) {}      
JOptionPane.showMessageDialog(null, devicesAndAdress);
    public void servicesDiscovered(int transID, ServiceRecord[] servRecord) { }
    public void serviceSearchCompleted(int transID, int responseCode) { }
    public void inquiryCompleted(int discType){}
  • To lock PC if mobile not found.
     package com.oksbwn.System;
public class Hibernate
// public static void main(String args[]) throws Exception
 public void doit() throws IOException{
       try {
           Connection connection = "btgoep://" +"THE DEVIC BT. ADDRESS" + ":9");
       catch (Exception e) {
     //r.exec("shutdown -h");//s for shutdown r restart
     Runtime rt = Runtime.getRuntime();
     rt.exec("C:\\Windows\\System32\\rundll32.exe user32.dll,LockWorkStation");