Shutdown Windows when pwd-protected screensaver is active...
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: Shutdown Windows when pwd-protected screensaver is active...

  1. #1
    Join Date
    Dec 1999
    Posts
    128

    Shutdown Windows when pwd-protected screensaver is active...

    Hi. I have an API question.

    I'm using ExitWindowsEx function to shutdown Windows (usually Win2K). It is working fine, it shutsdown, restarts, etc. If a screensaver is active and password protected though, it does not work at all.

    Is there a way to "persuade" Win2K to shutdown even if a password-protected screensaver is active?

    TIA
    -------------------------
    Nick A.

  2. #2
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362
    I dont have a definate answer for ya unfortunately, but I wonder if it is possible to somehow find the threadID of the screensaver and kill it. I can remember a few years ago fooling around with a program called Sub7 (by mobman) which could do this remotely but that was very very naughty!!!

  3. #3
    Join Date
    Dec 1999
    Posts
    128
    Thanx for the reply.

    It is indeed a naughty solution but i don't believe it will solve my problem. I'm using Win2K and it is most probable that the screensaver "tells" the system to lock itself so killing the ss will not unlock the system. This might work on a Win98 system.

    Thanx anyway...
    -------------------------
    Nick A.

  4. #4
    Join Date
    Apr 2004
    Location
    Austria
    Posts
    43
    you're trying to shutdown windows while the workstation is locked isn't it ?
    windows 2000 has no password protected screensavers, windows locks the workstation and then starts the screensaver.

    And I don't know any way to unlock a workstation without entering a password.
    Maybe you could try using the shutdown.exe windows has.

    just try a bit arount with it by calling it from the commandline with the paramter /?

    shutdown /?

    You can also call that from visual by using the shell cmd.

    That may help.. but I am not pretty shure.

    greetings UNI

  5. #5
    Join Date
    Dec 1999
    Posts
    128
    Originally posted by Illuvatan
    you're trying to shutdown windows while the workstation is locked isn't it ?
    windows 2000 has no password protected screensavers, windows locks the workstation and then starts the screensaver.
    Yes, that's what i'm trying to do... I know about all the things you mention here.

    And I don't know any way to unlock a workstation without entering a password.
    Maybe you could try using the shutdown.exe windows has.
    Windows has no such exe AFAIK. Perhaps you are talking about a third-party utility. In any case, do you know of any utility which will shutdown the system, even if it has been locked?

    That may help.. greetings UNI
    Unfortunatelly it didn't but thanks for your thoughts anyway...
    -------------------------
    Nick A.

  6. #6
    Join Date
    Apr 2004
    Location
    Austria
    Posts
    43
    I promise you there is a shutdown tool

    start your dos cmd and write

    shutdown -?

    you will get this output:
    Syntax: shutdown [-l | -s | -r | -a] [-f] [-m \\Computer] [-t xx]
    [-c "Kommentar"] [-d up:xx:yy]

    Keine Argumente Zeigt diese Meldung an (wie -?).
    -i Zeigt eine grafische Benutzeroberfläche an (muss die erste
    Option sein).
    -l Abmelden (kann nicht mit der Option -m verwendet werden).
    -s Fährt den Computer herunter.
    -r Fährt den Computer herunter und startet ihn neu.
    -a Bricht das Herunterfahren des Systems ab.
    -m \\Computer Remotecomputer zum Herunterfahren/Neustarten/Abbrechen.
    -t xx Zeitlimit für das Herunterfahren, in xx Sekunden.
    -c "Kommentar" Kommentar für das Herunterfahren (maximal 127 Zeichen).
    -f Erzwingt das Schließen ausgeführter Anwendungen ohne Warnung.
    -d [u][p]:xx:yy Grund (Code) für das Herunterfahren:
    u = Benutzercode
    p = Code für geplantes Herunterfahren
    xx = Hauptgrund (positive ganze Zahl kleiner als 256)
    yy = Weiterer Grund (positive ganze Zahl kleiner als 65536)
    sorry but my Windows is in German...

    This shutdown command triggers the window the blaster worm used to shutdown the computer. you will see a window that tells you that in a few seconds you computer will shut down.

    try this in your cmd shell

    shutdown -s -t 1000

    your computer will then display that window an tell you that he will shutdown in 1000 seconds.

    This can't be aborted without again using the shutdown command.

    type
    shutdown -a
    to abort the shutdown

    greetings UNI

  7. #7
    Join Date
    Dec 1999
    Posts
    128
    Originally posted by Illuvatan
    I promise you there is a shutdown tool

    sorry but my Windows is in German...
    Hmmm, i have Win2K SP4 English. No shutdown here. I even searched the whole C:\WinNT and subdirs.

    Perhaps it only exists in the German version?!?! Strange. Are you sure it's not an 3rd-party utility?
    -------------------------
    Nick A.

  8. #8
    Join Date
    Apr 2004
    Location
    Austria
    Posts
    43
    I use windows XP .. and I am 100% shure it is not a 3rd party tool

    But I guess you must have it. I always use the shutdown command on windows 2000 systems to remotely shutdown a computer..

    Justr try executing the command from the shell.. there must be a response..

    greetings UNI

  9. #9
    Join Date
    Dec 1999
    Posts
    128
    Originally posted by Illuvatan
    I use windows XP .. and I am 100% shure it is not a 3rd party tool

    But I guess you must have it. I always use the shutdown command on windows 2000 systems to remotely shutdown a computer..

    Justr try executing the command from the shell.. there must be a response..

    greetings UNI
    No, it's not there. I tried it, but i got an error. Perhaps it's a german-version tool... Thanks anyway...
    -------------------------
    Nick A.

  10. #10
    Join Date
    Apr 2004
    Location
    Austria
    Posts
    43
    Here is what I found on google about that:

    http://www.mkssoftware.com/docs/man1/shutdown.1.asp

    the shutdown.exe can be found on C:\Windows\System32\Shutdown.exe

    can't understand why it's not there..

    greetings UNI

    btw..
    pos eine o kairos stin patrida?

    ps:
    I know it's in the greek version too.. I have shut down some computers by using that tool

  11. #11
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Play with this code

    It works fine in Win2k advanced server (but I was logged as administrator)
    It locks workstation and, after 1 second uses api to try to shutdown.
    Attached Files Attached Files
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  12. #12
    Join Date
    Dec 1999
    Posts
    128
    Originally posted by Illuvatan
    Here is what I found on google about that:

    http://www.mkssoftware.com/docs/man1/shutdown.1.asp

    the shutdown.exe can be found on C:\Windows\System32\Shutdown.exe

    can't understand why it's not there..
    Hmmm. Probably this is the reason
    AVAILABILITY

    MKS Toolkit for System Administrators
    MKS Toolkit for Developers
    MKS Toolkit for Interoperability
    MKS Toolkit for Professional Developers
    MKS Toolkit for Enterprise Developers
    MKS AlertCentre
    Never mind. I'll try Cimperiali's code. Perhaps my problem has been solved...
    -------------------------
    Nick A.

  13. #13
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Let us know...

    ...it should work, but I tried only as administrator...Let us know...
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  14. #14
    Join Date
    Dec 1999
    Posts
    128

    Re: Let us know...

    Originally posted by Cimperiali
    ...it should work, but I tried only as administrator...Let us know...
    First of all, thanks for the help.

    I tried the code. Here's what it does.

    The call to ExitWindowsEx(EWX_FORCE, 0) causes the system to logoff, even though it was locked. (funny, i expected it to reboot/shutdown).

    If i change the EWX_FORCE to EWX_REBOOT (which is what i actually want to do), it does nothing (probably because it's locked).

    If i comment out the ExitWindowsEx call and call NtShutdownSystem directly, it shutsdown the system, and presents the screen which tells that it's safe to turn the power off.

    Any comments on that?

    P.S. I tried it as a domain user belonging to the local Administrators group (which is actually a PC administrator).
    Last edited by Nick A.; April 21st, 2004 at 07:45 AM.
    -------------------------
    Nick A.

  15. #15
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726
    try:
    Code:
    If ExitWindowsEx(EWX_POWEROFF Or EWX_FORCE, 0) = 0 Then
            NtShutdownSystem SHUTDOWN
    End If
    Last edited by Cimperiali; April 21st, 2004 at 08:32 AM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Page 1 of 2 12 LastLast

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center