{"id":4222,"date":"2014-03-30T09:24:33","date_gmt":"2014-03-30T09:24:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/lock-windows-desktop-from-java-after-timeout-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:24:33","modified_gmt":"2014-03-30T09:24:33","slug":"lock-windows-desktop-from-java-after-timeout-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/lock-windows-desktop-from-java-after-timeout-collection-of-common-programming-errors\/","title":{"rendered":"Lock windows desktop from Java after timeout-Collection of common programming errors"},"content":{"rendered":"<p>I want my java app to lock the windows desktop after a specific timeout. I have a timer which works fine, but I can&#8217;t seem to execute the command to lock the workstation.<\/p>\n<pre><code>javax.swing.Timer tim = new javax.swing.Timer(1000, new ActionListener() {\n   public void actionPerformed(ActionEvent e) {\n   System.out.println(\"CARD NOT PRESENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\");\n   \/\/ LOCK SCREEN\n   Runtime rt = Runtime.getRuntime();\n   Process pr = rt.exec(\"%windir%\/System32\/rundll32.exe user32.dll,LockWorkStation\");\n   }\n});\n<\/code><\/pre>\n<p>Is there some mistake in this? Or maybe an easier way to do this?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I want my java app to lock the windows desktop after a specific timeout. I have a timer which works fine, but I can&#8217;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(&#8220;CARD NOT PRESENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&#8221;); \/\/ LOCK SCREEN Runtime rt = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4222","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4222"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4222\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}