Announcement

Collapse
No announcement yet.

Rebooting properly with Windows from DOS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rebooting properly with Windows from DOS

    Well...under Windows 2000 I did a test, and my system shut down and rebooted via Windows...

    SHELL "start reboot"



    ------------------
    Amos

  • #2
    How to 'start shutdown' on WIN95?

    ------------------

    Comment


    • #3
      Richard,

      If you have PB/DLL 6.0 or higher, do this:

      ExitWindowsEx %EWX_REBOOT, 0
      ExitWindowsEx %EWX_SHUTDOWN, 0

      The first parameter in each one can be combined with:

      OR %EWX_FORCE

      This will FORCE the indicated action, regardless of programs currently
      running. However, you will lose any unsaved information in those programs.

      ExitWindowEx %EWX_LOGOFF, 0

      will logoff the current user.

      Hope this helps!

      Regards,


      ------------------
      Clay C. Clear

      Comment


      • #4
        There is a nice trick in DOS with rundll32...
        If you know the function name and the DLL it is in, you can call it with:
        rundll32 USER32.DLL,LockWorkstation
        (the name of the function is case-sensitive)

        You might have guessed that this will lock the computer for the current user... I couldn't find the function to close or reboot Windows, but it's probably in some other DLL in the System32 directory... Maybe somebody else knows this?

        ------------------
        Sebastian Groeneveld
        mailto:[email protected][email protected]</A>
        Sebastian Groeneveld
        mailto:[email protected][email protected]</A>

        Comment


        • #5
          You can do the same "trick" with the ExitWindowsEx API function... serach the BBS for RUNDLL32 and you should find some information on it.

          Note that that API function requires the 'flag' equates to be bitwise ORed together, and some combinations or equates will not work reliably on all platforms.

          Additionally, under Windows NT/2000/XP, the process must alter the security priveledge tokens to be allowed to shut down, and that cannot be done from DOS...

          However, PB/DLL 6.11 comes with a complete example application that shows how this is achieved.


          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            Why would you want to SHUT DOWN or RE-BOOT from within a PB-DOS Executable ?
            In PURE DOS or in WIN-DOS ?

            I have COLDBOOT.COM and WARMBOOT.COM which, when EXECUTED from within a
            PB-DOS program or run at the DOS prompt, either shut down the machine or
            re-boot it. To be used in PURE DOS only, otherwise the "Windows has not
            been shut down properly" ensues !

            Noticed that the FORUM now remembers my Password. Thanks Webmaster

            ------------------

            Comment


            • #7
              Otto,
              Just finished reading Lance's Article in this months
              PowerBASIC Gazette#028.
              I'm inspired!
              Id like to experiment with SHELL'n and RUN'n some Window
              Programs, more than just notepad anyway!
              I have a use for shutting down the machine, even if it does
              seem silly, some times I forget to run the routines I've
              created to copy files to & from floppy drive.

              I've tried: rundll32 shutdown

              Thats not it, can anybody move me along?

              Thanks - Rick



              ------------------

              Comment


              • #8
                Try this: (untested, off the top of my head)

                SHELL "RUNDLL32.EXE USER.EXE,ExitWindows"

                ... you could also try "RUNDLL32.EXE USER32.DLL,ExitWindows,0,0" instead of USER.EXE

                ... or you could try

                SHELL "RUNDLL32.EXE USER32.DLL,ExitWindowsEx,7,0"

                ... and to force a hung app to terminate, try changing the 7 to 23.

                Note 1: the capitalization of the "ExitWindows" and "ExitWindowsEx" portion is case-sensitive!

                Note 2: this approach will definitely not work under Windows NT/2000/XP, and for that you will need to use a 32-bit app based on the reboot example shipped with PB/DLL 6.1x.

                ------------------
                Lance
                PowerBASIC Support
                mailto:[email protected][email protected]</A>
                Lance
                mailto:[email protected]

                Comment


                • #9
                  Rick,

                  Thanks for drawing my attention to Lance's article in the PB Gazette #28 !

                  Reading it when it arrived in my Inbox, starting with "Windows API", I stopped
                  reading the rest, sorry Lance

                  Asked Lance for a copy and I am glad I did. "Shelling" Windows APIs from within
                  PB-DOS apps is definately an unexpected bonus for a PB-DOS only programmer I
                  shall have a good look at.



                  ------------------

                  Comment


                  • #10
                    Otto - Your welcome.

                    Lance - Thanks Very Much

                    "rundll32 user32,ExitWindows" Seems to work just fine.

                    -Rick

                    ------------------

                    Comment

                    Working...
                    X