Loading ...
Sorry, an error occurred while loading the content.

Re: [BATCH WORLD] Running a batch file on Windows' Exit

Expand Messages
  • Clint Alford
    If you are trying to run the batch when exiting windows, why not write a batch that exits windows for you. This way, when you are ready to reboot, shutdown or
    Message 1 of 9 , May 31, 2000
    • 0 Attachment
      If you are trying to run the batch when exiting windows, why not write a
      batch that exits windows for you. This way, when you are ready to reboot,
      shutdown or whatever... you just use the batch instead off start|shutdown,
      etc. Try this...

      wait a minute... I downloaded a buttload of your batch files when I was
      trying to learn batches... so you know this already, Gord... but here it is
      anyways.

      @echo off
      ::begin batch
      CLS
      C:
      CD\
      CALL (PATH TO BATCH YOU WANT TO RUN\BATCHFILENAME)

      IF !%WINDIR%==! GOTO DOSMODE

      ECHO.
      ECHO.
      ECHO OFF.BAT illustrates how there's more
      ECHO than one way to exit a batch program.
      ECHO --Gord Braun March 2000
      ECHO.
      ECHO R REBOOT WINDOWS ("Windows is now restarting")
      ECHO Q QUIT WINDOWS (shutdown computer)
      ECHO D REBOOT TO DOS (MS-DOS Mode)
      ECHO X EXIT THIS DOS SESSION (return to desktop)
      ECHO E END THIS BATCH PROGRAM (return to C prompt)

      ECHO.
      CHOICE /N /C:DXQER
      IF ERRORLEVEL 5 GOTO REBOOT
      IF ERRORLEVEL 4 GOTO END
      IF ERRORLEVEL 3 GOTO QUIT
      IF ERRORLEVEL 2 GOTO EXIT

      :DOS
      START %WINDIR%\EXITTO~1.PIF
      GOTO END

      :REBOOT
      %WINDIR%\RUNDLL.EXE user.exe,exitwindowsexec
      GOTO END

      :DOSMODE
      ECHO.
      ECHO The system appears to be running
      ECHO in MS-DOS Mode. OFF.BAT will only work
      ECHO in a DOS box under Windows.
      GOTO END

      :EXIT
      @EXIT

      :QUIT
      %WINDIR%\RUNDLL32.EXE User,ExitWindows

      :END
      ECHO.




      At 11:06 PM 5/30/00 -0600, gbraun@... wrote:
      >>At 09:40 PM 5/30/2000 -0000, you wrote:
      >>>I'm trying to run a batch file upon exiting windows. Whether it be
      >>>when you restart or shutdown.
      >>>Any ideas? I have feeling that I would have to call the batch file
      >>>from one of the sysedit programs. Please help if you can.
      >>>Thanks.
      >>
      >>Try running the batch file from win.ini, where it reads:
      >>
      >>[windows]
      >>load=
      >>run=c:\directoryname\batname.bat
      >>
      >
      >You could also put a shortcut to the batch file in your Programs/Startup
      folder.
      >
      >Gord
      >
      >><><><><><><><><><><><><><><><><><><><
      >Gord Braun
      >gbraun@...
      >http://www.accesscomm.ca/users/gbraun/
      >
      >
      >------------------------------------------------------------------------
      >Hot off the press- summer's here!
      >School's out and it's sizzling hot. Whether you're planning a
      >graduation party, a summer brunch, or simple birthday party,
      >shop GreatEntertaining.com before your next celebration.
      >http://click.egroups.com/1/4473/9/_/735058/_/959749318/
      >------------------------------------------------------------------------
      >
      >To Post a message, send it to: batchworld@...
      >
      >To Unsubscribe, send a blank message to: batchworld-unsubscribe@...
      >
      >
      Regards,

      Clint Alford
      Station 46 IS Department
      pager 888.250.9943

      Qui Desidererat Pacem Praeparet Bellum

      "640 K ought to be enough for anybody."
      -Bill Gates, 1981
    • Klaus Meinhard
      Ahmad, ... there are several possible solutions. A pure batch solution is indeed to set BootGUI=0 in MSDOS.SYS, and have your autoexec.bat execute win and then
      Message 2 of 9 , Jun 1, 2000
      • 0 Attachment
        Ahmad,

        > > Executing the batch file in question is in deed needed on exit and
        > > not on start up.

        there are several possible solutions. A pure batch solution is indeed to set
        BootGUI=0 in MSDOS.SYS, and have your autoexec.bat execute win and then your
        shutdown batch like this
        ...
        all commands now in autoexec.bat
        c:\windows\win.com
        mode ...... (enter the values for your screen here)
        call shutdown1.bat
        call shutdown2.bat

        which will probably work in win95 and in win98 if acpi is configured right.
        More help would be possible if you tell us exactly what you want to achieve.

        A look at http://www.barefootinc.com and their autoshutdown prog may be useful
        too.

        Viele Gr��e, best regards,

        *Klaus Meinhard*

        Author of the 4XBTM batch collection at
        http://home.t-online.de/home/K_Meinhard/
      Your message has been successfully submitted and would be delivered to recipients shortly.