Could someone pls test this code and post a message if it worked. (win95 - 98 - me - 2000 - xp). Program restarts windows immediatly so save all your work. It is written in dbpro.
Global true=1
Global false=0
restartComputer()
Function restartComputer()
OS$=GetOSVersion()
If inString(OS$,"Windows 95") Or inString(OS$,"Windows 98") Or inString(OS$,"Windows Me") :
Execute File "rundll32.exe", "user.exe, exitwindowsexec", "" : End
EndIf
If inString(OS$,"Windows 2000") :
Execute File "rundll32.exe", "shell32.dll, SHExitWindowsEx 2", "" : End
EndIf
If inString(OS$,"Windows XP") :
Execute File "shutdown", "-r -t 00", "" : End
EndIf
EndFunction
Function GetOSVersion()
Make Memblock 1,148
MemPTR=Get Memblock Ptr(1)
Write Memblock DWord 1,0,148
Load Dll "Kernel32",1
Call Dll 1,"GetVersionExA",MemPTR
Delete Dll 1
OSVersionInfoSize=Memblock DWord(1,0)
OSMajorVersion=Memblock DWord(1,4)
OSMinorVersion=Memblock DWord(1,8)
OSBuildNumber=Memblock DWord(1,12)
OSPlatformID=Memblock DWord(1,16)
OSCSDVersion$=""
For i=0 To 127
OSCSDVersion$=OSCSDVersion$+Chr$(Memblock Byte(1,20+i))
Next i
Delete Memblock 1
Select OSPlatformID
Case 1
If OSMinorVersion=0 Then result$="Windows 95"
If OSMinorVersion=10 Then result$="Windows 98"
If OSMinorVersion>10 Then result$="Windows ME"
EndCase
Case 2
If OSMajorVersion=3 Then result$="Windows NT 3.x"
If OSMajorVersion=4 Then result$="Windows NT 4.x"
If OSMajorVersion=5 And OSMinorVersion=0 Then result$="Windows 2000"
If OSMajorVersion=5 And OSMinorVersion=1 Then result$="Windows XP"
If OSMajorVersion=5 And OSMinorVersion>1 Then result$="Unknown Windows version"
If Len(OSCSDVersion$)>0 Then Result$=Result$+" with "+OSCSDVersion$+" installed"
EndCase
EndSelect
result$=result$+", (Build: "+str$(OSBuildNumber)+")"
EndFunction result$
Function inString(string$, sub$)
length1 = Len(string$)
length2 = Len(sub$)
For length = 0 To length1-length2
If sub$ = subString(string$, length, length+length2) Then ExitFunction true
Next length
EndFunction false
function subString(string$, startPos, endPos)
length = Len(string$)
string$ = Right$(string$, length-startPos)
string$ = Left$(string$, endPos-startPos)
EndFunction string$