Page 1 of 1 1
Topic Options
#158287 - 2006-03-03 08:41 PM Distinguish between XP and 2000?
cwhitmore Offline
Starting to like KiXtart

Registered: 2001-05-23
Posts: 102
Loc: Austin, Texas, USA
I need to copy a font to each Windows PC if it's not there already. I have Windows 2000 and XP users, which means that some are C:\winnt\fonts and c:\windows\fonts.
Is there an easy way for the script to find out what OS is running?

Top
#158288 - 2006-03-03 08:46 PM Re: Distinguish between XP and 2000?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Look at the @ProductType macro.

OS type. Possible values:
"Windows 95"
"Windows 98"
"Windows Me"
"Windows NT Workstation"
"Windows NT Server"
"Windows NT Domain Controller"
"Windows 2000 Professional"
"Windows 2000 Server"
"Windows 2000 Domain Controller"
"Windows XP Home Edition"
"Windows XP Professional"
"Windows XP Professional Tablet PC"
"Windows XP Media Center Edition"
"Windows XP Starter Edition"
"Windows Starter Edition"
"Windows Server 2003"
"Windows Server 2003 Domain Controller"
"Windows Server 2003 R2"
"Windows Server 2003 R2 Domain Controller"
"Windows Vista Home Edition"
"Windows Vista Professional"
"Windows Vista Professional Tablet PC"
"Windows Vista Media Center Edition"
"Windows Vista Starter Edition"
"Windows Vista Server"
"Windows Vista Domain Controller"

Top
#158289 - 2006-03-03 09:19 PM Re: Distinguish between XP and 2000?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Well a bit easier as you only need %WINDIR% which will tell where the WINDOWS/WINNT folder is located.

@DOS 5.0 for 2000 and @DOS 5.1 for XP

And here is a UDF to check the path.

Dim $Path
$Path=RemoteWinDir('some computer')
If $Path
'Remote Windows directory is: ' + $Path
Else
'Error getting remote path ' + @ERROR + ' - ' + @SERROR ?
EndIf

Function RemoteWinDir(optional $sComputer)
Dim $sComputer,$WinDir
$sComputer=IIf(Not $sComputer,'','\\'+Join(Split($sComputer,'\'),'',3)+'\')
If $sComputer
$WinDir = $sComputer+Join(Split(ReadValue($sComputer+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','SystemRoot'),':'),'$')
Else
$WinDir = ReadValue($sComputer+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','SystemRoot')
EndIf
If @ERROR
Exit @ERROR
Else
$RemoteWinDir = $WinDir
EndIf
Exit 0
EndFunction


Top
#158290 - 2006-03-03 09:22 PM Re: Distinguish between XP and 2000?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hmmm, don't think I would ever rely on %WINDIR% to tell me anything guaranteed about the OS... I personally like the @DOS idea the best.
Top
#158291 - 2006-03-03 09:26 PM Re: Distinguish between XP and 2000?
cwhitmore Offline
Starting to like KiXtart

Registered: 2001-05-23
Posts: 102
Loc: Austin, Texas, USA
Thanks for all the quick responses!
Top
#158292 - 2006-03-03 09:35 PM Re: Distinguish between XP and 2000?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Well if %WINDIR% is wrong on your system Shawn then you got a whole lot of problems as it probably won't even bootup.

Many of the default paths/keys in the registry read %WINDIR% not C:\WINDOWS or C:\WINNT

Top
#158293 - 2006-03-03 09:37 PM Re: Distinguish between XP and 2000?
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I'd use WMIQuery() to get a remote machine's OS
WMIQuery() will also get the installed dir
and then use RemotePath() UDF to convert it to UNC
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#158294 - 2006-03-03 09:39 PM Re: Distinguish between XP and 2000?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Ah k i see now - he doesn't really want to know the OS - he wants the path to the fonts ... in that case - %WINDIR% would be THE ONLY method to go with.
Top
#158295 - 2006-03-03 09:40 PM Re: Distinguish between XP and 2000?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
The OS doesn't really matter in this case. He was using that as an example of different folders.

He just wants to know where the FONTS folder is and the above methods will work just fine without using multiple UDF scripts.

C:\WINDOWS\FONTS, C:\WINNT\FONTS, E:\MyWINDOWS\FONTS, etc..

Top
#158296 - 2006-03-03 10:11 PM Re: Distinguish between XP and 2000?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Hey Rad,

Suggestion for your RemotePath

Code:
Function RemotePath($Path,optional $sComputer)
$sComputer=IIf(Not $sComputer,'','\\'+Join(Split($sComputer,'\'),'',3)+'\')
$RemotePath=$sComputer+Join(Split($Path,':'),CHR(36))
Endfunction


 

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.059 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org