Saving Electricity
Results 1 to 15 of 15

Thread: Saving Electricity

  1. #1
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020

    Saving Electricity

    OK, I am running Window XP Pro. I have the classic login screen activated.

    My question is, when window boots to this, is there some where in the registry that will run a script, similar to the:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

    That key runs anything after logging in.


    The reason I am looking for this is because, I want to make my ghosting process as energy efficient as possible.

    When Ghosting, there is a switch, -rb, that will reboot after it reimage the computer.

    The thing is, I like to ghost at night and just leave my computer there and go to sleep. However, I don't want to leave my computer on all night because I don't want to waste electricity.

    So, I like it that after ghosting and it reboots, it goes boots into Window and after 5 minutes of no movement, it runs a screensaver that I will create in VB. That screensaver will turn my computer off.

    I am not writing a virus or whatever, so please don't think I am going in that direction. Like I said, I just want my computer to be shut down after ghosting.

    Thanks

  2. #2
    Join Date
    Apr 2000
    Location
    Friern Barnet, London, England
    Posts
    46,565
    Here are all to locations of programs that you want to start automatically:

    1) Documents and Settings\username\Start Menu\Programs\Startup folder

    2) Documents and Settings\All Users\Start Menu\Programs\Startup folder

    in the Registry at:

    3) HK_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run

    4) HK_Local_Machine\Software\Microsoft\Windows\CurrentVersion\RunServices

    5)HK_Current_User\Software\Microsoft\Windows\CurrentVersion\Run

    6) HK_Current_User\Software\Microsoft\Windows\CurrentVersion\RunServices
    Nick.

  3. #3
    Join Date
    Feb 2001
    Location
    Adelaide, South Australia
    Posts
    6,447
    Maybe an easy way to handle that would be to put your custom screen saver in C:\Windows\System32, then go into the registry and change \HKEY_USERS\.DEFAULT\Control Panel\Desktop\SCRNSAVE.EXE from what it is now (probably logon.scr) to the name of your screen saver file.

    The basic effect there is that if your PC is left at the login screen until the screen saver activates, it'll run your custom screen saver (and therefore shut down). Once the PC is logged in it will run the logged-in user's screen saver, which would presumably be something else.
    Safe computing is a habit, not a toolkit.

  4. #4
    Join Date
    Apr 2000
    Location
    Friern Barnet, London, England
    Posts
    46,565
    If it's any help, the ExitWindows and ExitWindowsEx functions are what you need if you're using Visual Studio:

    http://msdn.microsoft.com/library/de...xitwindows.asp
    Nick.

  5. #5
    Join Date
    Jan 2000
    Location
    Toronto, ON, Canada
    Posts
    1,271
    Just an alternative thought, for a simpler but less sophisticated solution, you could always write a small batch file that executes the shutdown command, and have task scheduler run it automatically at a certain time that allows for Ghost to complete it's cycle (ie. 3 AM).

    Having said that, I've never tried it myself but it should work in theory.

    Anyways, just some food for thought.

    Cheers,
    KV

  6. #6
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    Nick,

    How come I don't see:

    4) HK_Local_Machine\Software\Microsoft\Windows\CurrentVersion\RunServices

    6) HK_Current_User\Software\Microsoft\Windows\CurrentVersion\RunServices

    The rest will run only after logging in which really defeats the purpose because no one is there to log in.


    This one might work since I forgot all about it.
    3) HK_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run

    As for the site that you posted, thank you for that too because that is what I am currently using in my customize screen saver. I have the program to shut down the computer and that works already. It is just firing it off.

    Tuttle, your suggestion is valid and might work. I am going to try it and let you know.

    KV, thank you for your suggestion but I think scheduler only works if you are log in. I am not sure about that but still, I kind want something a little more flexible and has no time dependencies.


    Thank you again Nick, Tuttle and KV! I will be back and give you a update.

  7. #7
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    OK, here is an update.

    Tuttle's suggestion worked. However, in the log in screen, the screen save got ran but window will not let it shutdown. The screen saver work because if I double click on it or replace it in the registry as the current screen saver, it shuts the computer down.


    Nick, that api ExitWindowsEx that you provided has some tweaking to do. Using by itself in Window XP will not work. It has to be used in the fashion as below.

    http://support.microsoft.com/kb/q176695/


    I think I need this api instead to shutdown window from the log in screen. However, I don't know how to use it. Nick, I know you know vb. You have any idea how to use it? If not, no biggie because I don't want to waste too much time on this.

    http://msdn.microsoft.com/library/de...shutdownex.asp


    Thanks again guys.

  8. #8
    Join Date
    Apr 2000
    Location
    Friern Barnet, London, England
    Posts
    46,565
    I haven't got around to using that particular call, I just remembered it from looking into it for a program that I'm intending to write when I can find the time.

    There are some good threads here from our sister site that explain how to use it:

    http://www.vbforums.com/search.php?s...der=descending
    Nick.

  9. #9
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    Thanks for the site but I got both api to work. However, still, the program gets fire off in the logging screen but will not let me shut the computer down. It is probably a security thing.

    Thanks Nick

  10. #10
    DrMDJ is offline Virtual PC Specialist!!!
    Join Date
    Apr 2000
    Location
    NJ, USA
    Posts
    8,428
    Here's another example (in C++, but you can translate to VB) of using the ExitWindowsEX call after setting the appropriate privilege for the process token. You'd need to set the privilege whether using ExitWindowsEx or the InitiateSystemShutdown (or its Ex variant) APIs.
    Please remember to post back whether your problem is resolved or
    not, so that others may gain from the knowledge.

  11. #11
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    Hi Doc,

    Those two api that you listed were already tried from above. I even set the privilege token too. Both works fine if the privilege token are set correctly. However, it only works after logging in. In the log in screen, the same set of code will not work because of security reason I think.

    I posted this site above.

    http://support.microsoft.com/kb/q176695/

    Thank You

  12. #12
    Join Date
    Feb 2001
    Location
    Adelaide, South Australia
    Posts
    6,447
    Try setting the EWR_FORCE bit in your call to ExitWindowsEx, if you're not already.
    Safe computing is a habit, not a toolkit.

  13. #13
    DrMDJ is offline Virtual PC Specialist!!!
    Join Date
    Apr 2000
    Location
    NJ, USA
    Posts
    8,428
    Sorry, must have read the initial posts too fast. Oh well...

    By the way, how are you initiating these Ghost backups? I take it you must be using the GUI within windows to kick them off.

    It would seem that to get your program to do what you want it to may require it running as a service (defined in HKLM\System\CurrentControlset\services) rather than a standard app. To run it as a service you'd need to either a) modify the program to be a viable service type program, or b) use a utility such a MS' SRVANY app (available in the NT resource kit and elsewher), which can act as a front-end to launch "regular" programs (EXEs) as services). Now not all programs can operate as services, but...

    Then again, there be something your particular program here is doing or some particular dependency that makes it not viable before logon. So let me throw out another option. One that wouldn't require messing with pragrams, services, security settings, registry stuff, etc. Is it resonable for you to put a floppy in your floppy drive once your ghost backup has been started? The reason I ask is because with a win98/me floppy (providing true dos) you could have a batch file (the autoexec.bat) that simply lauches one of the freely available DOS utilities that makes a APM call (to the bios) to poweroff a computer (ATX systems of course). One such utility is called ATXOFF. Ya put your floppy in that calls ATXOFF when ghosts starts, then when it reboots...
    Please remember to post back whether your problem is resolved or
    not, so that others may gain from the knowledge.

  14. #14
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    Tuttle, tried it already for both api. Thanks



    Doc, you da man!!!

    Nope, I am not using Window or the GUI to create/reimage my image. I go to DOS and run a batch file. That is the only way I feel safe when creating a new image. When you create an image in Window, it is like learning how not to paint yourself in the corner. Just a paranoid thing for me.

    Originally posted by DrMDJ
    Is it resonable for you to put a floppy in your floppy drive once your ghost backup has been started? The reason I ask is because with a win98/me floppy (providing true dos) you could have a batch file (the autoexec.bat) that simply lauches one of the freely available DOS utilities that makes a APM call (to the bios) to poweroff a computer (ATX systems of course). One such utility is called ATXOFF. Ya put your floppy in that calls ATXOFF when ghosts starts, then when it reboots...
    There is something better than a floppy disk. I have a bootup cd that I put ghost.exe on. I also have different batch files to fire Ghost.exe off.

    Just run Ghost and auto name
    3d.bat
    %CDROM%:\2003\Ghost.exe -auto


    Just run Ghost, auto name and when done, quit Ghost and continue the batch file
    3x.bat
    %CDROM%:\2003\Ghost.exe -auto -fx
    %CDROM%:\ATXOff.com


    Just run Ghost, auto name and reboot back to Window
    3r.bat
    %CDROM%:\2003\Ghost.exe -auto -rb


    Just run Ghost, auto name and burn directly to CD
    3c.bat
    %CDROM%:\2003\Ghost.exe -auto -split=650


    After the cd gets bootup, I just type in 3x and wholla. By the time it is done and turn off my computer, I am already in my bed asleep.

    I downloaded ATXOff from here.
    http://www.gknw.com/atxoff.html
    http://www.informatik.fh-muenchen.de...3/dostools.htm

    I asked a similar question about that tool ATXOff.com last year. At the time, no one replied. I asked if is there anyway to turn off the computer from DOS. Finally now, you gave me the name of that tool(atxoff) and I don't have to fire off the screen saver. When I have time, I am going to try out that first suggestion that you made regarding services. I just want to kill my curiosity with that too. The program/screen saver that I have can be converted into a COM/Serivces object in Visual Basic. I will keep you updated with that when I am done. Of course, since it is not a screen saver anymore, I will have to put a timer into that thing, or otherwise, it will just shut the computer off if it does work.


    Thanks again Doc.
    Last edited by Falcon Speed; October 25th, 2004 at 11:00 PM.

  15. #15
    DrMDJ is offline Virtual PC Specialist!!!
    Join Date
    Apr 2000
    Location
    NJ, USA
    Posts
    8,428
    Very good, glad ya got a solution. Yes the ATXOFF you linked is the one I was thinking of (there are a couple other such utilties around, but any one will do). Since you do this all from a boot disk/cd and DOS anyway using ATXOFF creates no additional issues.


    When I have time, I am going to try out that first suggestion that you made regarding services. I just want to kill my curiosity with that too.
    LOL. Like they say some times "Curiosity killed the cat". Then again, having a curiosity makes things more fun/interesting.
    Last edited by DrMDJ; October 26th, 2004 at 05:59 AM.
    Please remember to post back whether your problem is resolved or
    not, so that others may gain from the knowledge.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •