How to detect if its windows 7

Joined
Jun 25, 2010
Messages
4
Reaction score
1
I have written a program that I want to be able to detect if its running on xp,vista,seven
with vista its easy there is a folder called Vista86(or something) is there some way
(easy) for windows 7
ps where does windows 7 store its cookies,is there only one place ?
Thankyou
 
Joined
Mar 8, 2009
Messages
5,063
Reaction score
1,185
Hi eddiedd - Welcome to w7forums

What about typing "ver" from command line?

This gives the Windows version of all Windows operating systems. You should be able to use the version number to do what you are wanting. Using the version number would be a much better approach than using a folder listing.


Windows OS Version Numbers
Each version of Windows OS released by Microsoft has a particular version number and these version numbers are important for application developers while building application with compatibility.

And depending on your level of programming experience there are other ways such as "Determine Windows Version and Edition".
 

Nibiru2012

Quick Scotty, beam me up!
Joined
Oct 27, 2009
Messages
4,955
Reaction score
1,302
Cliff - you can also type in "winver" without quotes in the Search bar on the Windows Start Orb.

Just another way to get there.
 

Fire cat

Established Member
Joined
Mar 7, 2010
Messages
1,157
Reaction score
191
Cliff - you can also type in "winver" without quotes in the Search bar on the Windows Start Orb.

Just another way to get there.

Though, how are you supposed to do that with a software? A software that starts typing stuff in your search bar? Don't think so.

Clifford's suggestion could be implemented by running a batch file with the command, that then sends/stores the windows version for the software to continue working.
 
Last edited:

Nibiru2012

Quick Scotty, beam me up!
Joined
Oct 27, 2009
Messages
4,955
Reaction score
1,302
I stand corrected... I misunderstood the jist of the post.

Now, go do your homework!
 
Joined
Jun 25, 2010
Messages
4
Reaction score
1
Sorry I forgot to mention I am writing a Batch file and wish to determine what the windows type is , as the location of files is different on xp/vista
example here
@TITLE AnyNew by HighlandElectrix(TV)
@echo off
@mode con:cols=90 lines=20
rem this program will find where your cookies are stored (xp/Vista) and then look at each one and let you choose
rem whether to Keep or Delete it, if you keep it, a copy will be stored in a folder c:\goodcookies, so that next
rem time its found it will be ignored, also any cookies you choose to delete will be moved to c:\badcookies
rem and if found again will be deleted autometically. Hope you like it (freeware (c) Eddie Duncan-Dunlop 2010)
rem if you accidentally delete a good cookie, the go to the badcookies folder and cut/paste to goodcookies, or reverse
rem if you make a mistake, you can open the c:\badcookies or c:\goodcookies and correct the error
rem only designed for Internet Explorer
set version=v1.23.bat

echo (c) Eddie Duncan-Dunlop 2010 Version %version%  
color E0
rem E=bright yellow 0=Black
rem set the path to where all cookies are stored (vista is different)
set thepath="%userprofile%\cookies\"


rem -------------------- make sure its not Vista----------------------------------------------------------
if not exist %windir%\help\comexp.chm (
echo NOT WinodwsXP
pause)
if exist %windir%\system32\ndfetw.dll (
echo Vista this is the XP version
pause
set %thepath%="%AppData%\Microsoft\Windows\cookies\")

echo path is %thepath%

rem make a place to store the good/bad cookies if not already there--------------------------------
if not exist %systemdrive%\goodcookies (
md %systemdrive%\goodcookies
echo this is a list of good cookies that will left alone >%systemdrive%/goodcookies/AnyNew.inf
)

if not exist %systemdrive%\badcookies (
md %systemdrive%\badcookies
echo this is a list of bad cookies that will deleted automatically >%systemdrive%/badcookies/AnyNew.inf
)

rem --------------- make a small batch file to call for each cookie ---------------------------------------------
if exist %systemdrive%\%version% goto itsthere
echo if exist %%systemdrive%%\goodcookies\%%1 goto bye>%systemdrive%\%version%
if errorlevel 4 pause
echo if exist %%systemdrive%%\badcookies\%%1 set _what="d">>%systemdrive%\%version%
echo if exist %%systemdrive%%\badcookies\%%1 goto here>>%systemdrive%\%version%

echo set /P _what= %%1 Delete [D/enter] or Keep[K] .>>%systemdrive%\%version%
echo If /i "%%_what%%"=="" set _what="d">>%systemdrive%\%version%
echo If /i "%%_what%%"== "D" set _what="d">>%systemdrive%\%version%
echo If /i "%%_what%%"== "K" set _what="k">>%systemdrive%\%version%
echo If /i "%%_what%%" == ""k"" copy /y %%1 %systemdrive%\goodcookies\%%1^>nul >>%systemdrive%\%version%
echo If /i "%%_what%%" == "k" copy /y %%1 %systemdrive%\goodcookies\%%1^>nul >>%systemdrive%\%version%
echo :here >>%systemdrive%\%version%
echo If /i "%%_what%%" == ""d"" move /y %%1 %systemdrive%\badcookies\%%1^>nul >>%systemdrive%\%version%
echo :bye >>%systemdrive%\%version%

rem ----------------- its there -----------------------------
:itsthere

rem ---------- store the current path to folder and call the little bat file for each cookie found -------------
pushd %thepath%
for %%n in (*.txt) do (
call %systemdrive%\%version% %%n %thepath%
)
popd

rem ECHO

echo Closing in 6 Seconds
for /l %%A in (1,1,6) do (
<nul (set/p z=%%A )
>nul ping 127.0.0.1 -n 2
)

echo.

rem ----- delete all the bad cookies as listed in folder from the normal storage place -----------------------
pushd %systemdrive%\badcookies
for %%n in (*.txt) do if exist %thepath%\%%n del %thepath%\%%n
popd

rem only need to keep the filename(not the contents) so shorten them to "MT" to save room on Hdrive
for %%n in (%systemdrive%\badcookies\*.txt) do echo MT>%%n
for %%n in (%systemdrive%\goodcookies\*.txt) do echo MT>%%n

set thepath=
set _what=
exit
 
Joined
Mar 8, 2009
Messages
5,063
Reaction score
1,185
After seeing what you have posted, I know you will not have any trouble understanding this script. :)
Code:
REM operating system  : typing "ver" from commandline
REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM Windows XP        : Microsoft Windows XP [Version 5.1.2600]
REM Windows Vista     : Microsoft Windows [Version 6.0.6001]
REM Windows 7         : Microsoft Windows [Version 6.1.7600]
REM
REM WinXP, WinVista, Win7

 @ECHO OFF
 Color f0&CLS

 set WinVersion=""
 FOR /f "tokens=1,2* delims=[]" %%a in ('ver') DO (
   if "%%~b"=="Version 5.1.2600" set WinVersion=WinXP
   if "%%~b"=="Version 6.0.6001" set WinVersion=WinVista
   if "%%~b"=="Version 6.1.7600" set WinVersion=Win7
 )
 if "%WinVersion%"=="" Goto :Ver_not_found
 Echo %WinVersion%
 pause
Goto :EOF


:Ver_not_found
  Echo This script did not recognize the OS version in use.
  pause
Goto :EOF


:EOF
 

Nibiru2012

Quick Scotty, beam me up!
Joined
Oct 27, 2009
Messages
4,955
Reaction score
1,302
It's all Greek to me! LOL!

Reminds me of my days on my old Atari 520ST writing programs in BASIC! :stupido:
(Actually, attempting to write programs in BASIC.)

I really respect people who are able to do this type of thing as shown above.

Must be my ADD or whatever, gets confusing real quick, sort of like trying to drive through Dallas TX on the interstate during Friday PM rush hour! :driver:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top