Razorback
NewsProjectsGuidesResourcesContact
 Guide Index Quick Links


Cheap APM Poweroff Workaround for Windows NT 4.0 on MPS Systems

Created on September 2, 2021

So, there's a good handful of guides out there showing you how to set up Windows NT 4.0 to power off after shutting down using an updated HAL from Softex, a little something you can take out of Service Pack 6a... but strangely, if you try to do this on a dual CPU system using HALMPS.DLL, it may not work; the system could just hang and not show any dialog box even when you've followed the correct procedure. So how do you get back that convenience later operating systems like Windows 2000 provided?

Well, there are a few things you'll need... for one, you need an ATX-based dual CPU computer with an APM implementation. (If yours is AT-based or only implements ACPI for power management, this workaround is useless.) Your boot partition should have both Windows NT and MS-DOS installed; a 2GB CF card and a larger hard drive on a separate storage channel or controller should be perfect. MS-DOS should be installed first, but you don't need to install it the traditional way. Use the command SYS C: from an existing MS-DOS boot floppy when you have an empty FAT16 partition ready, and you can tell Windows NT Setup to install directly to that same partition without formatting or converting it.

After getting everything set up, you'll want to create a couple of batch scripts, being POWEROFF.BAT and AUTOEXEC.BAT. You'll also need two programs, Infsect and Blacklight's DOS shutdown utility. Put these programs in paths you can remember (and DOS can easily work with), preferrably a common executable path like C:\DOS. If ATTRIB.EXE for MS-DOS is not already present, that must be loaded as well. A conventional MS-DOS 6.22 boot floppy found off the internet should contain this program.

The first script, POWEROFF.BAT, is to be executed by Windows NT. Create this script wherever you want, and load it with the following contents:

@ECHO OFF

REM Creates a file for MS-DOS's AUTOEXEC.BAT to check for
echo. > c:\power.off

echo Changing default boot option
attrib -s -h -r c:\boot.ini
c:\dos\infsect c:\boot.ini -s "boot loader" -g default=C:\
c:\dos\infsect c:\boot.ini -s "boot loader" -g timeout=0
attrib +s +h +r c:\boot.ini

echo Restarting the computer
echo [version] > c:\restart.inf
echo Signature="$Windows NT$" >> c:\restart.inf
echo [DefaultInstall] >> c:\restart.inf
echo DelFiles=restart >> c:\restart.inf
echo [restart] >> c:\restart.inf
echo restart.inf >> c:\restart.inf
echo [DestinationDirs] >> c:\restart.inf
echo restart=24 >> c:\restart.inf
echo. >> c:\restart.inf
C:\WINNT\System32\rundll32.exe setupapi,InstallHinfSection DefaultInstall 129 c:\restart.inf

Now, Windows NT does not have a way to call a DLL file directly like Windows 9x for restarting the computer, but creating a self-destroying INF file at the root of the C: drive and executing with option 129 (always reboot) is an ideal workaround. Compiling a program that calls the Windows API to restart instead would be better, really, but the INF technique using nothing but ECHO commands shows that you can do it without the need for that. Once you've saved this batch script, you can create a shortcut to it on the desktop and/or Start menu for convenience.

Essentially, this script temporarily opens up BOOT.INI for writing, and Infsect is used to change the default boot option. Of course, MS-DOS also has to know that it's being told to handle the job of powering off the system, and this requires editing AUTOEXEC.BAT at the root of the C: drive. The contents of this file will vary depending on your needs, but essentially, you'll want to splice in a new section like this:

@ECHO OFF
REM Essential commands like t
PROMPT $p$g
PATH C:\DOS

REM Executed only if Windows NT ran POWEROFF.BAT
IF NOT EXIST C:\POWER.OFF GOTO NORMAL
DEL C:\POWER.OFF
C:\DOS\attrib -s -h -r c:\boot.ini
C:\DOS\infsect c:\boot.ini -s "boot loader" -g default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
C:\DOS\infsect c:\boot.ini -s "boot loader" -g timeout=3
C:\DOS\attrib +s +h +r c:\boot.ini
shutdown s
REM End of poweroff routine

:NORMAL
REM Normal AUTOEXEC.BAT routines go here...

POWEROFF.BAT created the POWER.OFF dummy file that AUTOEXEC.BAT checks for when booting into MS-DOS. When it finds this, the script deletes the dummy file, temporarily opens up BOOT.INI again for restoring the original boot settings, and then powers off the computer. Keep in mind that the name of the option used to boot into Windows NT may be different depending on where your boot drive is located, so check BOOT.INI with Notepad to be sure, and modify AUTOEXEC.BAT if it needs to be something else.

Now, try the script and see if it works! Fun fact, since Windows NT 3.51 does not appear to have any way to pull off APM poweroff even with the latest updates, this solution becomes very useful on systems running it. All you have to do is replace the INF echo commands with this program that takes care of restarting the computer: restart.exe

Now see it in action...

Watch video: Cheap APM Poweroff Workaround for Windows NT 4.0 on MPS Systems


Comments

No comments for this page.

Leave a Comment

Name: (required)

Website: (optional)

Maximum comment length is 1000 characters.
First time? Read the guidelines

SORRY NOT GONNA SHOW THIS IN TEXT BROWSER
Enter the text shown in the image: