No announcement yet.

Laptop Half Arsed Shutdown Control System...

  • Filter
  • Time
  • Show
Clear All
new posts

  • Laptop Half Arsed Shutdown Control System...

    ShutControl - Shutdown Control Software for Laptops



    '98 Peugeot 306
    Project Status: I sold it ages ago!


    The ultimate shutdown control software for laptops.

  • #2
    This is a very interesting system. Thanks for all your detailed information and for sharing the files.

    The embedded cpu board I was using won't suspend or hibernate, so I am now going to use an old Dell laptop w/ docking station that became available. My plan was to use Windows to Suspend after a few minutes when it switched to battery power, and to Hibernate a few minutes after that. Then use the ignition power line to control a relay that would toggle the power button on the dock to turn it back on.

    I was wondering why you weren't using Suspend any during your process, was it just to keep things simple and consistent or did you try using Suspend also and it didn't work properly? I haven't tested the Suspend->Hibernation cycle yet with RR running, so maybe that isn't going to work if music is playing.

    Zotac N630I-D-E M/B w/ Nvidia 7100, E5300 cpu, Xenarc 700IDT, M2-ATX, XP, RR & DFX 5.1.


    • #3
      I didn't bother with suspend because the cars battery life is very important to me (its bad enough as it is). Hibernate is the ideal option. I was getting frustrated watching the host of batch files run and go crazy, so I'm recoding the lot in Java - a proper coding language.

      I will post back on here in about 1 hour when I'm done. I've noticed a few more niggles, and I figure I may as well restart the machine immediately after going onto battery (for a clean run) then after restarting, make the machine hibernate, then after resuming from hibernate, load all the apps. I might even make a GUI if I can be bothered.

      '98 Peugeot 306
      Project Status: I sold it ages ago!


      The ultimate shutdown control software for laptops.


      • #4
        Thanks for the software ideas - I may be able to use this to shutdown my GPS so that I don't have startup problems.

        I'm doing something very similar, with a couple more bells and whistles:

        1) A delay circuit that waits for about 12 minutes after the ignition goes off before killing power to the PC. This is so I can stop and get gas, or leave the machine on when I pull into the garage and connect to my network

        2) A separate relay to power my usb audio, LCD screen, etc. using the external keyboard connector on my laptop, so that everything goes up/down together (power only goes off when hibernation is complete).

        This works so well that I'm surprised more people don't use laptops.....


        • #5
          Hey bud,
          Great program, well it doesnt work for me but its exactly what I need.

          I followed all the instructions and when I remove the power of my laptop it opens a java window and says Are You Sure? and I get a button "Abort"

          Can you help me fix this.



          • #6
            I used to use this same concept a couple of years ago when I first got started. It works great for people using inverters or others using alternative power supplies such as laptop adapters.
            I still reccommend a shutdown controller at the least though. This will work, but if your computer hangs or you use a different method of shutting down other than shutdown, you are prone to a dead battery.
            Shutdown controllers cost about $35.00 and are welll worth it. I suggest the
            THIS ONE
            I have used it before and actually used it for about a year to switch on and off my inverter which power my ATX computer (350watt PSU), USB hub and a few other small items.

            Sorry didnt read the whole post, I thought this was another schematic for shuting down your computer and cutting power using relays.
            My bad
            New Age Garmin - Skin for RR
            New Age Slider - RR SKin In Progress
            "It's called CODE because I don't want you to know"


            • #7
              Is there such a thing as a shutdown controller for a laptop? It would be nice if I could get rid of the brickpack.


              • #8
                I wrote a laptop menu program once that had battery information in it in vb.

                Wouldnt it just be posible to have a watchdog program watching for battery and then run the system command shutdown instead of all this? btw did I say I hate java?

                I am sure this info is around here already.

                'battery info
                Private Declare Function GetSystemPowerStatus Lib "kernel32" (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As Long
                Private Declare Function SetSystemPowerState Lib "kernel32" (ByVal fSuspend As Long, ByVal fForce As Long) As Long
                Private Type SYSTEM_POWER_STATUS
                    ACLineStatus As Byte 'Checks to see if your connected to the walloutlet or not
                    BatteryFlag As Byte 'Battery status
                    BatteryLifePercent As Byte 'precentage left
                    Reserved1 As Byte 'Dont use
                    BatteryLifeTime As Long 'Total time left of your battery
                    BatteryFullLifeTime As Long 'Total UPtime of your battery
                End Type
                    If SystemPower.ACLineStatus = 0 Then
                        Label4.Caption = "BATTERY"
                    ElseIf SystemPower.ACLineStatus = 1 Then
                        Label4.Caption = "AC POWER"
                    End If
                    If SystemPower.BatteryFlag = 1 Then
                        Label4.Caption = "HIGH" + vbNewLine + Label4.Caption
                    ElseIf SystemPower.BatteryFlag = 2 Then
                        Label4.Caption = "LOW" + vbNewLine + Label4.Caption
                    ElseIf SystemPower.BatteryFlag = 4 Then
                        Label4.Caption = "CRITICAL" + vbNewLine + Label4.Caption
                    ElseIf SystemPower.BatteryFlag = 128 Then
                        Label4.Caption = "NO BATTERY" + vbNewLine + Label4.Caption
                    End If
                You get the idea I just cut some of my code from my vb project... it should be really easy to call the dos command

                Usage: shutdown [/i | /l | /s | /r | /a | /p | /h | /e] [/f]
                    [/m \\computer][/t xxx][/d [p:]xx:yy [/c "comment"]]
                    No args    Display help. This is the same as typing /?
                    /?         Display help. This is the same as not typing any options
                    /i         Display the graphical user interface (GUI).
                               This must be the first option
                    /l         Log off. This cannot be used with /m or /d option
                    /s         Shutdown the computer
                    /r         Shutdown and restart the computer
                    /a         Abort a system shutdown.
                               This can only be used during the time-out period
                    /p         Turn off the local computer with no time-out or warning.
                               This can only be used with /d option
                    /h         Hibernate the local computer.
                               This can only be used with the /f option
                    /e         Document the reason for an unexpected shutdown of a computer
                    /m \\computer Specify the target computer
                    /t xxx     Set time-out period before shutdown to xxx seconds.
                               The valid range is 0-600, with a default of 30
                    /c "comment" Comment on the reason for the restart or shutdown.
                               Maximum of 127 characters allowed
                    /f         Force running applications to close without forewarning users
                    /d [p:]xx:yy  Provide the reason for the restart or shutdown
                               p indicates that the restart or shutdown is planned
                               xx is the major reason number (positive integer less than 256)
                               yy is the minor reason number (positive integer less than 65536)


                • #9
                  Goddamn you man, I just spent the last 4 hours learning how to use VB (from scratch) and make an application that did everything. At the moment, its kinda buggy, its terminating itself for no reason. I will post all the source on here, and see if someone can sort it.

                  My code is really messy, so I do apologise, but I have never used this language before, and it is still being debugged.


                  '98 Peugeot 306
                  Project Status: I sold it ages ago!


                  The ultimate shutdown control software for laptops.


                  • #10
                    I will look at it tomorrow when I get to work...I dont have on my laptop.

                    My vb laptop project was actually a shell replacement because the people using it were to dumb to use xp, and its been in use by about 80 people for the past 7 years, so vb works pretty good for this type of thing.

                    I looked at the form code in notepad. Why are you running bat files? I would just run the shutdown cmd from vb so you can check for response codes. If you want the different commands to be customizable make an ini or cfg file that has the differnt options for the things you want to do and then the command they are supposed to run.

                    command=shutdown.exe /s
                    command=shutdown.exe /r
                    command=shutdown.exe /h
                    command=shutdown.exe /p /d
                    command=shutdown /a
                    Then you could set it up to check for response codes...or even run dos batch scripts if you want.

                    also I think you could skip all this and use direct calls like:
                    Application.SetSuspendState(PowerState.Hibernate, true, true);
                    using System.Runtime.InteropServices;
                    public static extern int ExitWindowsEx(int uFlags, int dwReason);
                    also maybe some of the hibernate issues need this fix


                    • #11
                      Having just restarted my project after yonks of not doing anything, my EPIA now refuses to output video... so I am now using an old P3 1.2 laptop, so this could be exactly what I need.

                      However, upon downloading to test, it comes up with .net framework error:

                      See the end of this message for details on invoking
                      just-in-time (JIT) debugging instead of this dialog box.

                      ************** Exception Text **************
                      System.NullReferenceException: Object reference not set to an instance of an object.
                      at ShutControl.ShutControl.GetFileContents(String FullPath, Int32 j)
                      at ShutControl.ShutControl.EWFCheck(Boolean EWFWrite)
                      at ShutControl.ShutControl.ShutControl_Load(Object eventSender, EventArgs eventArgs)
                      at System.Windows.Forms.Form.OnLoad(EventArgs e)
                      at System.Windows.Forms.Form.OnCreateControl()
                      at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
                      at System.Windows.Forms.Control.CreateControl()
                      at System.Windows.Forms.Control.WmShowWindow(Message& m)
                      at System.Windows.Forms.Control.WndProc(Message& m)
                      at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
                      at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
                      at System.Windows.Forms.Form.WmShowWindow(Message& m)
                      at System.Windows.Forms.Form.WndProc(Message& m)
                      at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
                      at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
                      at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

                      ************** Loaded Assemblies **************
                      Assembly Version: 1.0.5000.0
                      Win32 Version: 1.1.4322.2032
                      CodeBase: file:///c:/windows/
                      Assembly Version: 1.0.2427.10689
                      Win32 Version: 1.0.2427.10689
                      CodeBase: file:///C:/test/ShutControl.exe
                      Assembly Version: 1.0.5000.0
                      Win32 Version: 1.1.4322.2032
                      CodeBase: file:///c:/windows/assembly/gac/
                      Assembly Version: 1.0.5000.0
                      Win32 Version: 1.1.4322.2032
                      CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
                      Assembly Version: 7.0.5000.0
                      Win32 Version: 7.10.6001.4
                      CodeBase: file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
                      Assembly Version: 1.0.5000.0
                      Win32 Version: 1.1.4322.2032
                      CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll

                      ************** JIT Debugging **************
                      To enable just in time (JIT) debugging, the config file for this
                      application or machine (machine.config) must have the
                      jitDebugging value set in the section.
                      The application must also be compiled with debugging

                      For example:

                      < jitDebugging="true" />

                      When JIT debugging is enabled, any unhandled exception
                      will be sent to the JIT debugger registered on the machine
                      rather than being handled by this dialog.


                      • #12
                        This VB app is going to be really helpfull. Could you please add an option to standby instead of hibernate and also the option to disable the restart feature.

                        Thanks a tonne....


                        • #13
                          Originally posted by rumy View Post
                          This VB app is going to be really helpfull. Could you please add an option to standby instead of hibernate and also the option to disable the restart feature.

                          Thanks a tonne....

                          If you can outline in a bit more detail what you would like to do. From what I gather you want to...

                          Battery detected > Laptop enters standby

                          AC detected > Laptop resumes from standby

                          In this instance, would you want the laptop to load any applications when resuming from standby - or simply resume? In this case, I can make a simple fix whereby you enable the EWF option, but instead of shutting down, it will enter standby.

                          Wait for the new release

                          '98 Peugeot 306
                          Project Status: I sold it ages ago!


                          The ultimate shutdown control software for laptops.


                          • #14
                            The scope is pretty much endless on all of this, I could make it turn off when the battery hits a certain level, or perform a certain action. If anyone does have any more requests, I'll be glad to try and put them in.

                            Remember though, this is the first ever time I've used VB - so my coding is horrific and it is nowhere near optimised, but I'm glad I've got this far.

                            '98 Peugeot 306
                            Project Status: I sold it ages ago!


                            The ultimate shutdown control software for laptops.


                            • #15
                              Is there any reason for the error I am getting at the top?