Working on a Hibernate timer .bat script

I am trying to write a simple script that will put my Win.7 computer into 'Hibernate' after a designated number of minutes. I want this to open from my desktop, prompt me to input how many minutes I would like to wait, and then execute the operation when
the time comes. I have other ideas on how to improve the script, but I would really just like basic function operable. I am very new to writing scripts and started with someone else's script, which looks like this:
HibTimer.bat
@echo off
set /p time=How many minutes until hibernate? :
cls
for /L %%A in (%time%,-1,0) do (
echo shutdown -h in %%A minutes
ping localhost -n 60 >null
cls
shutdown -h
As is, this has worked decently. The two big issues I have with it are:
1) Inputting high values upon the prompt causes the hibernation to occur immediately.
2) The script creates a blank desktop icon titled 'null'
Can someone please help me understand what this script is doing (particularly after the "for /L" bit?) And how I could maybe improve it to better deal with my issues?
Honestly, I would have preferred to have started from scratch, but I am trying to get something working sooner than later to resolve a (completely different) reoccuring issue I am experiencing with my built-in Windows inactivity hibernate schedule.
Thanks 1000x

Now that is a pretty code! (something I can actually follow ^_^)
I fine-tuned it a bit, and included the actual command at the end and it seems to be working much more smoothly than my original.
HibTimer.bat
@echo off
set /p timeout=How many minutes until hibernate?
echo Computer will hibernate in %timeout% minutes
set /a timeout=%timeout%*60
timeout /t %timeout% > nul
shutdown -h
A couple things to keep in mind with this script, I've found that pressing any key beyond the initial prompt will trigger the hibernation immediately (I wonder if there's a way to minimize the window to prevent this from happening accidentally?), and the
only way to abort the process is by closing out the window. I'm not sure if this would work or not, but perhaps bringing up an ordinary command prompt would allow me to command an abort if I wanted, and also help to prevent accidental immediate hibernation?
Finally, I wanted to comment on something I noticed the original script would do that I don't believe this one does, and that is the read-out now doesn't tick down. [ie. before if I input 10 minutes, after 2 minutes passed, it would display that the event
would occur in 8 minutes.] Not really that important in terms of functionality, but definitely a neat trick.
Anywho, thank you so much for you assistance Forest brook! I'll be sure to update this thread if I make any further changes, and will definitely check back to see if you or others have any more input.
:) Happy Programming! (:

Similar Messages

  • Cannot launch vivado simulator 2015.1: behav/compile.bat' script "Please check that the file has the correct 'read/write/execute' permissions"

    Hi,
    I'm trying to run a verilog simulation using the vivado simulator 2015.1 on Windows 7.
    I get the following error when I attempt to launch simulation:    
    ERROR: [USF-XSim-62] 'compile' step failed with error(s) while executing 'D:/projects/axi/axi_test_system/axi_test_system.sim/sim_1/behav/compile.bat' script. Please check that the file has the correct 'read/write/execute' permissions and the Tcl console output for any other possible errors or warnings.
    The tcl console repeats the same message, "Please check that the file has the correct 'read/write/execute' permissions"
    I cannot find any problem with the permissions.  I believe that windows will always execute a .bat file.   Within the same project, I can run elaboration, synthesis and implementation without problems. 
    Any idea why the simulation compile script won't run?
    Thanks,
    Ed

    Hi,
    Thanks very much for your detailed reply. These were the right questions based upon what I told you.   
    However, I took the code home last night and ran it on my webpack 2014.2 release.   It still failed, but I got completely different error messages.   These messages correctly pointed me to an undeclared signal in my testbench. Once fixed, the compile worked and the simulator launched. 
    This morning, I fixed the signal name in my 2015.1 setup, and it also compiled and launched correctly. 
    So, the problem wasn't actually related to file permissions.  It seems like the 2015.1 error message may be broken compared to 2014.2.  
    I was running the Vivado GUI, clicking on "Simulate > Run Behavioral Simulation"
    Thanks again for your help. 
    Regards,
    Ed  
      

  • Need a bat script to check Server status remotly.

    Hi,
    I need bat script to check server status remotly (Ping) for multiple servers. It should generate a txt file for result.
    Thanks.

    Hi Ravi,
    To ping multiple computers and generate report cia cmd, please refer to the script below, the "fnm" is computer name list and the "lnm" is the result, and you can save the script below as .bat file:
    @echo off
    set fnm=d:\test1\computers.txt
    set lnm=d:\test1\ping.txt
    if exist %fnm% goto Label1
    echo.
    echo Cannot find %fnm%
    echo.
    Pause
    goto :eof
    :Label1
    echo PingTest STARTED on %date% at %time% > %lnm%
    echo ================================================= >> %lnm%
    echo.
    for /f %%i in (%fnm%) do call :Sub %%i
    echo.
    echo ================================================= >> %lnm%
    echo PingTest ENDED on %date% at %time% >> %lnm%
    echo ... now exiting
    goto :eof
    :Sub
    echo Testing %1
    set state=alive
    ping -n 1 %1
    if errorlevel 1 set state=dead
    echo %1 is %state% >> %lnm%
    Refer to:
    Explain the Batch script to ping multiple computers
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Working with TimeZone variables in UCCx script

    Hi Team
    I'm wondering if you guys could help me to find out the best way to work with TZ variables in UCCx script.
    Because of different countries customer has a branches, I need to setup different TimeZones for each country handled by the same centralized UCCx.
    In this post they use Java to work with TZ, however, but I prefer another way to work with TZ variables:
    https://supportforums.cisco.com/discussion/11851751/how-make-uccx-holiday-script-timezone-aware
    My idea is to work with Time Zone variables in the script, so what I did was to create different TZ variables and each one of the them assigned the proper timezone based on the country, so depending of the Trigger involved (DNIS), I can find witch country this call came from and give the right timezone.
    The problem I have is that at the time I want to add or subtract two variables of TZ, I got an error because of the syntax. I've been trying different options, but until now, no luck.
    Would you mind you guys who had been working on this let me know what is the right syntax to add or subtract TimeZone variables un UCCx?
    Thanking you in advance
    Martin

    Hi
    I've been working on TZ's recently... see this post:
    https://supportforums.cisco.com/discussion/12474756/how-check-daylight-saving-within-uccx-script
    My approach in the scripts was that basically I allow the department to set their opening hours in the timezone of their choice.
    They have a management web page served from CCX that accepts start/end times each day, and a timezone. That all gets stored in XML.
    In the script, based on that information I get the current time in whatever timezone is set, and compare that to the XML open/close times.
    Similarly for holidays, I get the current date/time in the holiday TZ and compare the holidays to that.
    Aaron

  • Bat script to share a folder

    I'm trying to share a folder using a bat script
    I'm trying something like this, but it doesn't work 
    NET SHARE test=P:<folderLocation> /GRANT:domain\username,FULL
    it's giving me system error 5 - access is denied even tho I'm the domain admin :S 

    Hi,
    If you want to create a share folder via script, I suggest we tried to refer to the following articles.
    Create a Shared Folder and Assign Share Permissions
    http://gallery.technet.microsoft.com/ScriptCenter/6309d93b-fcc3-4586-b102-a71415244712/
    Create a Shared Folder
    http://gallery.technet.microsoft.com/scriptcenter/d654b1ff-1091-4173-affd-67d5d09b0923
    If you have some trouble in editing the script, I suggest we could ask in the script forum.
    The Official Scripting Guys Forum!
    http://social.technet.microsoft.com/Forums/en/ITCG/threads/
    Regards,
    Andy

  • Need Windows bat script help

    Apparently I've been in Unix land a little too long, because I'm trying to do something in a windows .bat scirpt that i know is possible in a Kornshell. I just don't know for sure if it is possible on windows.
    I am trying to assign a variable the value of a command. More specifically, I'm trying to assign the variable as the contents of a file.
    So in a Kornshell I would do something like this...
    DBS_NAME=$(cat DBS_NAME.txt)
    echo $DBS_NAME
    So I have gotten this far in the .bat script...
    set DBS_NAME=type DBS_NAME.txt
    echo %DBS_NAME%
    but everything I've tried to resolve the "type" command (to display the contents of the file) is not working, I keep ending up with the text of what is after "set DBS_NAME=" on the output.
    Does anybody know if this is possible in windows?
    TIA,
    Robert

    The echo is there to display the value of DBS_NAME for testing.
    I'm actually trying to read this in so I can pass it to a maxl command line, and instead of the variable passing the App.DBname (contents of the file), it is passing 'type C:\DBS_NAME.txt' to my maxl script, and so it is failing.
    Here is the test bat script...
    set DB=type C:\DBS_NAME.txt
    essmsh C:\Test.mxl %DB%
    and its maxl output below...
    (I overwrote the user, password and server below)
    Notice that it is failing on the word 'type'. This should be the App.DB being passed (the contents of the file), but instead it is still only passing the text of the command.
    MAXL> login <user> <password> on <server>;
    OK/INFO - 1051034 - Logging in user [000694098].
    OK/INFO - 1051035 - Last login on Friday, November 05, 2010 2:08:03 PM.
    OK/INFO - 1241001 - Logged in to Essbase.
    MAXL> display variable on database type;
    ERROR - 1242021 - (1) Syntax error near ['type'].
    MaxL Shell completed

  • Extensions like Ghostery, WOT or AdBlock stop working after two or three times. Restarting the webpage in a new tab the extensions will work again for several times and then stop again. Has anybody an explanation or a workaround for this bug in Safari 5?

    Extensions like Ghostery, WOT or AdBlock stop working after two or three times. Restarting the webpage in a new tab the extensions will work again for several times and then stop again. Has anybody an explanation or a workaround for this bug in Safari 5?

    Remove the extensions, redownload Safari, reload the extensions.
    http://www.apple.com/safari/download/
    And if you really want a better experience, use Firefox, tons more choices and possibilities there.
    Firefox's "NoScript" will block the Trojan going around on websites. Best web security you can get.
    https://addons.mozilla.org/en-US/firefox/addon/noscript/
    Ghostery, Ad Block Plus and thousands of add-ons more have originated on Firefox.

  • Sometimes my computer takes too long to connect to new website. I am running a pretty powerful work program at same time, what is the best solution? Upgrading speed from cable network, is it a hard drive issue? do I need to "clean out" the computer?

    Many times my computer takes too long to connect to new website. I have wireless internet (time capsule) and I am running a pretty powerful real time financial work program at same time, what is the best solution? Upgrading speed from cable network? is it a hard drive issue? do I only need to "clean out" the computer? Or all of the above...not to computer saavy.  It is a Macbook Pro  osx 10.6.8 (late 2010).

    Almost certainly none of the above!  Try each of the following in this order:
    Select 'Reset Safari' from the Safari menu.
    Close down Safari;  move <home>/Library/Caches/com.apple.Safari/Cache.db to the trash; restart Safari.
    Change the DNS servers in your network settings to use the OpenDNS servers: 208.67.222.222 and 208.67.220.220
    Turn off DNS pre-fetching by entering the following command in Terminal and restarting Safari:
              defaults write com.apple.safari WebKitDNSPrefetchingEnabled -boolean false

  • Why is it when I go to open a file in Photoshop cc I get a "Could not complete your request because of a program error".  I have uninstalled and re-installed software,  It works for a short time then I get that error again when i go to open a file.  Thank

    @Why is it when I go to open a file in Photoshop cc I get a "Could not complete your request because of a program error".  I have uninstalled and re-installed software,  It works for a short time then I get that error again when i go to open a file.  Thank you!

    Without proper system information and other details like what files you work with  nobody can tell you much. From corrupted prefs to issues with your PS swap file to actual problems with the fiel storage this could be anything.
    Mylenium

  • My MacBook Pro won't connect to the Internet via wifi but it worked fine on ethernet cord...I tried running diagnostic but it didn't work:((((  it happen every time if I restart the modem and/or router

    My MacBook Pro won't connect to the Internet via wifi but it worked fine on ethernet cord...I tried running diagnostic but it didn't work:((((  it happen every time if I restart the modem and/or router.. Any idea how to fix this?

    Hello Rattisate,
    Sorry to hear you are not able to connect to Wi-Fi on your MacBook Pro.  I would be concerned about this too.  You can find information on how to troubleshoot this in the following article:
    Troubleshooting Wi-Fi issues in OS X Lion and Mac OS X v10.6
    http://support.apple.com/kb/HT4628
    Follow the steps in the section labeled, "Symptom: My Mac does not connect to the Internet."
    Thank you for posting in the Apple Support Communities.
    Best,
    Sheila M.

  • Saving to SharePoint works only half the time for Windows 7 Users--all the time for Windows XP users

    We have a SharePoint 2010 Environment with hardware load balancing, 2 WFEs, 2 Apps Servers and 1 SQL Server. This was built in October 2013. Office Integration and Saving back to SharePoint works all of the time for users on XP. It works sporadically for
    users on Windows 7. When Windows 7 users do the following:
    Opening an Office Document from computer and saving it to SharePoint
    Within a Document Library, using Save As from an opened document
    When selecting in a Document Library from the Document Tab> “New” and then the desired content type
    Send> Save to SharePoint from within Office Document
    They may either be brought to the SharePoint library (correct) or to My Documents (incorrect).
    In the case of number 1 (Opening an Office Document from computer and saving it to SharePoint)--using Save and Send will sometimes open the SharePoint library and sometimes open My Documents.
    Our URL is https://CompanyName.domainname.com/Sites/SiteCollectionName
    The intermediary "Sites" is actually a blank path.
    When My Documents is opened I've noted with Fiddler (a web debugger) that we get a 404 on sites:
    Could this be the issue?

    Some things to double check:
    Ensure that you have sticky sessions enabled on your load balancer
    Check that your WebDav calls are making it to the server
    Ensure that you have a root site collection in all your web apps
    Just out of curiosity, what is the http request look like for the 404 error?
    Chris Givens CEO, Architecting Connected Systems
    Blog Twitter

  • I had my iphone 5 replaced at the apple store as of a broken sleep button and i was wondering if they would replace again as i think it may of happend again as it works most of the time but theres an odd click where it wont work.

    I had my iphone 5 replaced at the apple store as of a broken sleep button and i was wondering if they would replace again as i think it may of happend again as it works most of the time but theres an odd click where it wont work.

    Yes.

  • As a novice computer user, I wonder why I'm often getting "white-out" (program/app I'm working in goes totally blank onscreen). If it makes a difference, I'm working 99% of the time on battery, not AC, power. What causes this?

    As a novice computer user, I wonder why I'm often getting "white-out" (program/app/site I'm working in goes totally blank onscreen). This is when I'm Internet online. If it makes a difference, I'm working 99% of the time on battery, not AC, power. Some of the possibilities I'm guessing are: glitches in my Verizon FiOS Wi-Fi providership?; staying too long on a site that's waiting for me to finish and "Submit"?; computer hardware prob (yikes, I hope not! It's brand new). Any ideas out there?

    When this 'white-out' occurs, is the display 100% white with no error message and no menu bar?
    Does this occur when you are using Wi Fi or connected to the Internet via the Ethernet cable?
    Ciao.

  • One headphone does not work or works 50% of the time.  What is best way to resolve?

    one headphone does not work or works 50% of the time.  What is best way to resolve?

    First of all, I'd recomend resetting the iPod. Do this by pressing the 'Menu' and 'Center" buttons for 10 seconds or until the Apple logo appears.
    If this doesn't work, then it sounds like a hardware fault.
    To identify the issue, if you have one, try plugging the iPod into a speaker through the dock. If this works, then the issue is with the headphone jack. If not then the logic board is dead.  If the iPod is less than a year old, then it can be repaired by Apple for free. Just book an appointment for the Genius bar.
    If not then, you could see about sending it to an iPod Repair Company, such as my own. A replacement headphone jack would cost £30.00 in the UK, including next day delivery. Other companies you could try would beUKiPodRepairs, but we guarantee to beat any quote that you get.
    Hope that this helps,
    Mark Sweeney
    Dr Pod Founder

  • The disk drive in my iMac 8,1 has stopped working, so I now use an LG 8x Slim Portable that works.  However, every time I use the LG drive, I lose contact with my Time Machine back-up drive that has to be deleted and reinstalled.  Help!

    The disk drive in my iMac 8,1 has stopped working, so I now use an LG 8x Slim Portable that works.  However, every time I use the LG drive, I lose contact with my Time Machine back-up drive that has to be deleted and reinstalled.  Help!

    It's not Logic that can't find them, it's your Komplete apps, though if you did exaclty as you say I can see no reason why they can't.
    Do you know where the apps installed them in the first place? I chose a non-standard locarion for mine, but I'm sure it installs sounds to your documents folder/native instruments/name of app.
    Go into the prefs of each app and choose the library location button on the library tab and point it to the relevant folder in documents/native instruments and see if that works
    jake

Maybe you are looking for

  • Win7/32 Preview Problem with Adobe Reader XI

    we need Win7/32 with Adobe Reader XI. The Preview function in the explorer does not yet work. Windows is in German, Adobe Reader in English Thanks for your help

  • Recent Leopard Update Messes up Cinema Display Firewire Ports

    Okay, this is really odd. I have a Lacie Porsche DVD-RWDL Firewire drive hooked up to my Mac Pro via my 23" Cinema display. The cinema display firewire cable was connected directly to the back of the mac pro. Lastly my iSight was connected to the ope

  • A problem about GP parameters mapping.

    Hi, all. I tried to group two parameters together. Those are both structured parameter with cardinality 0.n. But when I groupped them together , the cardinality became 0.1 . I had no idea how this happened. Can anyone give me a hand? Thanks

  • Turn Off Snap to Grid

    I accidentally turned on "Snap to Grid." Now I can't get it to turn off. Clicking F5 does nothing, trying to turn it off in the view menu does nothing. Any suggestions?

  • Safari crash when viewing mjpeg on ios 6

    I have found that after some time of viewing mjpeg on any web page safari browser quits unexpectedly. Furthermore, any mjpeg-viewing app, which I found in the AppStore have the same problem, all of them quits unexpectedly after some time. The problem