Microsoft KB Archive/68224

= Basic Program to Reboot or &quot;Cold&quot; Reboot the Machine =

Article ID: 68224

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft Cinemania 97 Standard Edition

-



This article was previously published under Q68224



SUMMARY
This article describes three ways to reboot your machine from within a Basic program.

WARNING: Be sure to CLOSE all open files before rebooting the computer so as not to lose buffered data.

This information applies to Microsoft QuickBasic versions 4.0, 4.0b, and 4.5; to Microsoft Basic Compiler 6.0 and 6.0b for MS-DOS; and to Microsoft Basic Professional Development System (PDS) 7.0 and 7.1 for MS-DOS.



Method 1
The first method of rebooting the machine requires only Basic code. This program sends a command directly to the keyboard I/O port using Basic's OUT statement. This causes the keyboard controller chip to reboot the machine just as if you had pressed CTRL+ALT+DEL on the keyboard. Note that this command is supported only on the AT and higher classes of machines. This example will not work on the IBM PC- or XT-class machines or clones. ' REBOOT.BAS DEFINT A-Z DEF SEG = &H40     ' If the memory location &H0072:0073 in the BIOS POKE &H72, &H34    ' data area contains &H1234, then this will cause POKE &H73, &H12    ' a warm reboot (no self-test or memory                    ' count). Anything else causes does a cold reboot ' (self-test and memory count). DEF SEG            ' Return to Basic's default segment. Command% = &HFE    ' Reset Processor command. Port% = &H64       ' Keyboard I/O Port OUT Port%, Command% ' Reboot

Method 2
Another way to reboot your machine is to jump directly to the ROM BIOS initialization code (which normally executes automatically when the machine's power is first turned on). This method of rebooting the machine should work on all members of the IBM PC and PS/2 family of computers, as well as the clones of these machines.

To use this method, however, your chosen language must have support for &quot;pointers to functions&quot; as in C or assembly. Because Basic does not support a function pointer data type, you must write a C or assembly procedure to jump to the ROM BIOS boot code. You can call this C or assembly procedure from your Basic program.

Two separate articles in this Knowledge Base describe how to reboot the MS-DOS computer. One article describes using C alone to reboot, and the other article describes using C with inline assembly code to reboot. To see these articles, query on the following words:

reboot and machine and QuickC

For more information about calling C from Basic, query on the word BAS2C. For more information about calling assembly language from Basic, query on the word BAS2MASM.

Method 3
You can also call IBM ROM BIOS interrupt 19 hexadecimal (25 decimal) to reboot the computer. For example: 'Note: To use the Interrupt routine, you must load the Quick library 'QBX.QLB for Basic PDS 7.0 or 7.1 (or QB.QLB for QuickBasic 4.x) using 'the /L switch when you begin QBX.EXE (or QB.EXE for 'QuickBasic 4.x). When you choose the Make EXE File option from the 'Run menu, the environment will then link with QBX.LIB (or QB.LIB). ' 'The following include file must also be present:

'$INCLUDE: 'QBX.BI' '  but for QuickBasic 4.x, you must instead include 'QB.BI'

DIM regs AS RegType CALL Interrupt(&H19, regs, regs) 'Reboot the computer

Additional query words: QuickBas BasicCom 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10 restart boot

Keywords: KB68224

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.