Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsWindows VistaWindows XPWindows MeWindows 98Windows 95Virtual PCInternet ExplorerOutlook ExpressWindows MediaSecurity
Related Topics
MS Server ProductsMS OfficePC HardwareMore Topics ...

Windows Forum / Windows Vista / Administration / May 2008

Tip: Looking for answers? Try searching our database.

Detect Vista in Logon Script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 04 Apr 2007 21:00 GMT
How can we detect for Windows Vista in our Logon Script?  Previously we could
use OSVER.exe or even a 3rd party app OSVER61.exe to detect all versions of
windows through Server 2003.  When OSVER is run on Vista it returns nothing,
not even unknown, just nothing.  Is there a way to detect if a user is
running Vista or not?  Maybe a newer version of OSVER, or another command
that we can run in a batch file?  TIA
JerryM (ID) - 05 Apr 2007 02:48 GMT
Just like before, Control panel -System

> How can we detect for Windows Vista in our Logon Script?  Previously we
> could
[quoted text clipped - 5 lines]
> running Vista or not?  Maybe a newer version of OSVER, or another command
> that we can run in a batch file?  TIA
D - 05 Apr 2007 13:54 GMT
> How can we detect for Windows Vista in our Logon Script?  Previously we
> could
[quoted text clipped - 5 lines]
> running Vista or not?  Maybe a newer version of OSVER, or another command
> that we can run in a batch file?  TIA

When I was writing my logon scripts, I checked for environment variables.
Ex - if %os%==Windows_NT then do winxp stuff (as we have no nt4 or even 2k
pro machines on the network, this worked properly)

For Vista, I noticed that the %os% variable is the same, so I had to check
something else, but I needed to do this before my xp check, so now I do
something like this...

if "%allusersprofile%"=="C:\ProgramData" goto WinVista
if %os%==Windows_NT goto WinXP

::if it gets here, assume 9x base

exit

:Winvista
@Echo Windows Vista Operating System Detected
goto fin

:winxp
@Echo Windows XP Operating System Detected

:fin

This is an example of a script I use daily, and I've not yet had a problem
with it detecting the wrong OS.

Hope this helps.

D
Dave - 05 Apr 2007 14:24 GMT
D,

Thank you, that's EXACTLY what I was looking for.

-Dave

> > How can we detect for Windows Vista in our Logon Script?  Previously we
> > could
[quoted text clipped - 36 lines]
>
> D
D - 05 Apr 2007 14:55 GMT
> D,
>
[quoted text clipped - 47 lines]
>>
>> D

Dave,

Glad to help out.

Doug
GTS - 06 Apr 2007 04:18 GMT
D
One  minor suggestion.   Rather than hard coding the drive letter (which
fails on my dual boot xp/vista machine with Vista on D:) I would do it this
way.

if "%allusersprofile%"=="%HOMEDRIVE%\ProgramData" goto WinVista

> When I was writing my logon scripts, I checked for environment variables.
> Ex - if %os%==Windows_NT then do winxp stuff (as we have no nt4 or even 2k
[quoted text clipped - 26 lines]
>
> D
D - 09 Apr 2007 13:45 GMT
That's a good idea, but in an AD domain based environment, that might not
work as many admins populate the map home drive (letter) to (path) which
then sets the %homedrive% variable.  But, like I said it's a good idea to
not code the drive letter.  Instead, and I believe this is what you had
meant to say, was to use %systemdrive%

Thanks for the tip though

Doug
> D
> One  minor suggestion.   Rather than hard coding the drive letter (which
[quoted text clipped - 33 lines]
>>
>> D
GTS - 09 Apr 2007 15:40 GMT
Good clarification.  Thanks.

> That's a good idea, but in an AD domain based environment, that might not
> work as many admins populate the map home drive (letter) to (path) which
[quoted text clipped - 42 lines]
>>>
>>> D
youyang - 05 Apr 2007 15:47 GMT
Hi, here is the code I used in my batch File:

ECHO *Detecting Windows Version...

VER | findstr /i "5.1.2600" > nul
IF %ERRORLEVEL% EQU 0 GOTO XP

VER | findstr /i "5.2.3790" > nul
IF %ERRORLEVEL% EQU 0 GOTO 2003

VER | findstr /i "6.0.6000" > nul
IF %ERRORLEVEL% EQU 0 GOTO VISTARTM

:XP
ECHO *Windows XP
REM TODO
GOTO EOF

:2003
ECHO *Windows Server 2003
REM TODO
GOTO EOF

:VISTARTM
ECHO *Windows Vista RTM

Signature

Thanks

大家有时间听一下《雪花》

> How can we detect for Windows Vista in our Logon Script?  Previously we
> could
[quoted text clipped - 5 lines]
> running Vista or not?  Maybe a newer version of OSVER, or another command
> that we can run in a batch file?  TIA
Dave - 05 Apr 2007 17:16 GMT
Thanks Youyang, I'll keep this one in mind also.

We might be pushing our luck here, but does anyone have an idea on how to
determine the "flavor" of Windows Vista?  We probably don't want to run the
same commands for our users who have Vista Home vs. Business/Ultimate.

-Dave

> Hi, here is the code I used in my batch File:
>
[quoted text clipped - 31 lines]
> > running Vista or not?  Maybe a newer version of OSVER, or another command
> > that we can run in a batch file?  TIA
D - 05 Apr 2007 20:26 GMT
I don't have Vista home on a machine nearby, but on Vista Business (and
probably Ultimate and Enterprise), there are 2 variables - USERDOMAIN and
USERDNSDOMAIN.  So, using the info I orginally posted, and assuming you were
on a domain, you could do something like...

if %userdomain%==mydomain goto vistabiz

or even...

if "%userdomain%"=="" goto nodomain
::do vista business stuff here...

goto fin
:nodomain
::system not on domain, so assume vista home
::
:fin

One thing you can do to see what environment variables to use would be to
open a command prompt and type in SET and hit enter.  If you have a Vista
Home machine near you, compare the variables to see what is on the Vista
Home machine that might not be on the Business machine, or vice versa, and
then use that variable in your script.

Also, you could talk to whomever is resonsible for imaging and deploying
machines in your location and ask them to set the machines up with a global
environment variable via the default user registry, but I think you'd be
better off looking at the existing environment variables.

Again, hope this helps.

Doug

> Thanks Youyang, I'll keep this one in mind also.
>
[quoted text clipped - 42 lines]
>> > command
>> > that we can run in a batch file?  TIA
shmoib - 25 May 2008 19:01 GMT
just do a query for the registry key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\ProductName

it should return Windows Vista or XP

Signature

shmoib

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.