{"id":2410,"date":"2020-09-17T18:26:53","date_gmt":"2020-09-17T16:26:53","guid":{"rendered":"http:\/\/outofmymind.scanlen.com\/?p=2410"},"modified":"2020-09-17T18:27:21","modified_gmt":"2020-09-17T16:27:21","slug":"time-to-hibernate","status":"publish","type":"post","link":"https:\/\/outofmymind.scanlen.com\/?p=2410","title":{"rendered":"Time To&#8230; Hibernate"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"http:\/\/outofmymind.scanlen.com\/wp-content\/uploads\/2011\/05\/Topic-Windows.jpeg\" alt=\"\" class=\"wp-image-1706\"\/><\/figure><\/div>\n\n\n\n<p>I have found now that on a number of occasions that I cannot power my machine off when I wanted to as it is still running a script or something, but I also don&#8217;t just want to leave it on just because I cannot sit and wait for it to finish.&nbsp;<\/p>\n<p>Ever experience something similar?&nbsp; I also didn&#8217;t want to just download another application just to hibernate my machine on a schedule so I decided to look if there was a more &#8220;old-school&#8221; command line method that I could use that may be able to do it for me&#8230;<\/p>\n\n\n\n<p>After some searching I found a post over at <a rel=\"noreferrer noopener\" href=\"https:\/\/www.howto-connect.com\/automatically-hibernate-windows-10-scheduled-time\/\" target=\"_blank\">howto-connect.com<\/a> that used the command TIMEOUT at the command line.  It uses the number of seconds to wait until the command is run.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timeout \/t xx \/NOBREAK > NUL &amp;&amp; shutdown \/h<\/code><\/pre>\n\n\n\n<p>So running the above command and replacing the xx with 60 (for 1 minute) or 1500 (for 25 minutes) will let the computer &#8220;wait&#8221; for that period of time before running the command to the RIGHT of the &amp;&amp;  &#8211; so in the above example:   shutdown \/h<\/p>\n\n\n\n<p>Now all that is good and well, but having to try and work out how many seconds 48 minutes is requires a calculator for me. So I got to thinking&#8230; what if I could create a batchfile that would prompt me how many minutes I wanted to wait for, then automatically multiplied it by 60 and then put that result in as the value in the timeout section of the command&#8230;<br><br>Step #1 would have to be to set a variable called minutes. This would be for the user to type in how many minutes to wait for.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set \/p minutes=Enter Minutes To Wait: <\/code><\/pre>\n\n\n\n<p>OK now to take that %minutes% variable and multiply it by 60 (seconds).\u00a0 After looking around I found an interesting article by<a rel=\"noreferrer noopener\" href=\"https:\/\/www.robvanderwoude.com\/battech_math.php\" target=\"_blank\"> Rob van der Woude<\/a> about doing calculations at the command line.\u00a0In this case a new variable would be created called Result, this from taking the %minutes% and multiplying it by 60. The command I was looking for was:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set \/a Result = %minutes% * 60<\/code><\/pre>\n\n\n\n<p>And then finally to use the %Result% variable in the timeout command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timeout \/t %Result% \/NOBREAK > NUL &amp;&amp; shutdown \/h<\/code><\/pre>\n\n\n\n<p>So finally we had all the bits of the code, time now to create a batchfile and bring it all together.  I decided to name the file HIBERNATE.CMD  Here is the  contents of the batchfile:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@echo off\nset \/p minutes=Enter Minutes To Wait: \necho.\necho Counting down the time...  Please Wait...\nset \/a Result = %minutes% * 60\ntimeout \/t %Result% \/NOBREAK > NUL &amp;&amp; shutdown \/h<\/code><\/pre>\n\n\n\n<p>I am pleased to say that although not a pretty GUI or any fancy bells or whistles, it works like a charm for me! Till next time&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have found now that on a number of occasions that I cannot power my machine off when I wanted to as it is still running a script or something, but I also don&#8217;t just want to leave it on just because I cannot sit and wait for it to finish.&nbsp; Ever experience something similar?&nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-2410","post","type-post","status-publish","format-standard","hentry","category-windows"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=\/wp\/v2\/posts\/2410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2410"}],"version-history":[{"count":12,"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=\/wp\/v2\/posts\/2410\/revisions"}],"predecessor-version":[{"id":2423,"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=\/wp\/v2\/posts\/2410\/revisions\/2423"}],"wp:attachment":[{"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outofmymind.scanlen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}