Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine version of Windows

Status
Not open for further replies.

scoundrel86

Programmer
Aug 21, 2004
4
US
I need to determine the version of windows that my compiled QB4.5 program is running under. In my program, I am shelling out to run a batch file that is created from within the program. In order to run the programs properly from the batch file, I need to specify either the use of COMMAND for Win9x or CMD for WinXP. For this reason, I need to determine the version of windows so that I can shell properly. Any suggestions?
 
In windows there is 1 or more API calls that can be used to
find the OS.

for Qbasic try
shell "ver"

or shell "ver >my.fil"
then,
open "my.fil" for input as #1
while not eof(1)
line input #1,LL$
if LL$<>"" then OS$=LL$
wend
close
 
That's great and a big duh on my part. But now I have another question: How can I tell if I am running in a DOS window under Win9x or if the computer was booted to only DOS, where I can't run other programs from my quickbasic program such as Adobe Acrobat? The VER command returns the same response either in a DOS window or when booted to Win98se DOS.
 
I suspect that would have to be a windows program calling some api, finding the "window" but then if you are running in 98 dos ....

Perhaps, If you have a little win program, maybe it will
return an error if running in booted dos mode
 
windows xp/nt still have the command program in addition to the cmd program so you don't really need to worry about this - (all versions of windows have the command program)

%, 2004
 
Here's my suggestion:

Code:
'--Get OS info.  (Thanks to Buff1)
CLS
SHELL "ver > Temp.fil"
OPEN "temp.fil" FOR INPUT AS 11
WHILE NOT EOF(11)
    LINE INPUT #11, Aline$
    IF Aline$ <> "" THEN OS$ = Aline$
WEND
CLOSE #11
KILL "temp.fil"

'--Get global variable.  (Per MiggyD)
WinOpen$ = ENVIRON$("windir")
WinOn$ = "Windows Running?: "
IF LEN(WinOpen$) > 1 THEN
    WinOn$ = WinOn$ + "Yes, most likely"
ELSE
    WinOn$ = WinOn$ + "Most likely DOS"
END IF

'--Display Info
PRINT
PRINT "Operating System: "; OS$
PRINT WinOn$
PRINT

'--Write down info
OPEN "Answers.txt" FOR APPEND AS 14
PRINT #14, "Operating System: "; OS$
PRINT #14, WinOn$
PRINT #14,
CLOSE #14

Following is from the "Answers.txt" it generated:

Operating System: Windows 95. [Version 4.00.1111]
Windows Running?: Most likely DOS

Operating System: Windows 98 [Version 4.10.1998]
Windows Running?: Most likely DOS

Operating System: Windows Millennium [Version 4.90.3000]
Windows Running?: Yes, most likely

Testing Info:
I'm currently on Win ME (which doesn't allow: Start in DOS mode).

I have both a '95 and a '98 Boot disk. Started system from floppies (which generated the first two results--sorry, I don't plan on finding a spare drive and re-installing either of these, you'll have to test this out on your own.)

This code was NOT tested on an NT or XP system. Results obtained may vary or be inconclusive {see below}.
--end test info--

I Hope This Helps you. Be cautious! In XP there's the capability to "do not let program detect running under windows" (or something to that effect.)

Again, HTH.
--MiggyD
 
You are incorrect

I'm currently on Win ME (which doesn't allow: Start in DOS mode).

Windows ME does allow booting to dos you have to use the magic button F8


%, 2004
 
Ummm, no I am not "incorrect"...

I used your "magic" button and this is what I got:

1) Normal
2) Start Bootlog.txt
3) Safe Mode
4) Step-by-Step confirmation

At the bottom it said:

F5 for Safe Mode, Shift-F8 for Step Confirmation.

I'm pretty certain I would not have stated that without first checking my system. Maybe there's a different build of ME (or an "Upgrade to ME") that you used. Don't know, don't matter. As I said before, "you'll have to test this out on your own." I was only giving you the results per the current machine I was on.

Good luck,
--MiggyD
 
-- WinME sucks --

XP allows Dos boot... BUT... it loads windows first...
(so what's the point... right?)

You have to log on to go to the Dos Mode...

If you are still using WinME... WHAT IS WRONG WITH YOU ???

J/K ;-)

Good Luck,
Josh

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
XP allows a DOS boot? How do you do this?

The best way to use dos is to use a boot floppy disk. Find an old computer, running Win 3.1, go to the File Manager and tell it to make a boot disk.
 
If you do this then you won't beable to access your harddrive unless it is FAT32(although by default windows is installed on NTFS which you would need a third party program in order to read NTFS in dos
sysinternal.com make a program called NTFSDos
which they have two version
1). Is Free but it will only let you have read-only access to your harddrive.
2). You have to pay for and you get full access.

%, 2004
 
In XP you can use the magic F8 and boot to the command prompt in safe mode. Perhaps that's what is meant.

I just had an occurance to do that with a computer plagued
by worms and such.

BTW, I have a client running XP at his office and it seems to get viruses (like maybe 5 per day) whereas the W98 I have here doesnt with the same antivirus and same firewall.

Any ideas anyone ?
 
First boot into safe mode
login as the admin
disable system restore
go to the c drive go to the propertys of this folder "System Volume Information"
go to the security tab
give all the users on the system full permission for this folder(go to advanced check the box starting with Replace~1) click ok, click ok
^this is a location on xp that viruses like to hide since by default windows does not give any user on the system access to this dir(so when you do a virus scan the program can not search here because none of the users have permissions to access this directory).

go to this location C:\Documents and Settings
go to these locations and delete the contents of each folder
C:\Documents and Settings\username\Cookies
C:\Documents and Settings\username\Local Settings\Temp
C:\Documents and Settings\username\Local Settings\Temporary Internet Files

C:\WINDOWS\Temp

These are alot of locations that viruses hide
also this person might have p2p software which is where the main way viruses are spread.

Also make sure that windows has all of the lastest patches


%, 2004
 
forgot...
after you do this reboot to safemode with networking then try going here

click "Scan Now. It's Free!"
check auto fix then have it scan the harddrive
then you should be done although you may want to also use software that is specificly for adware/spyware a very good one is ad-aware(made by Lavasoft) they have a free version


%, 2004
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top