I want my java app to lock the windows desktop after a specific timeout. I have a timer which works fine, but I can't seem to execute the command to lock the workstation.
javax.swing.Timer tim = new javax.swing.Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("CARD NOT PRESENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
// LOCK SCREEN
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("%windir%/System32/rundll32.exe user32.dll,LockWorkStation");
}
});
Is there some mistake in this? Or maybe an easier way to do this?