JSI Tip 8657. How can a script determine of the client computer is a workstation or server?

Jerold Schulman

November 7, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today


If your script needs to determine if it is running on a workstation or a server, you can use the following code snippet:

if not "%OS%"=="Windows_NT" goto notNTset rf="%TEMP%ProductName_%RANDOM%.reg"regedit /a %rf% "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersion"set srv=NOfor /f "Tokens=*" %%s in ('type %rf%^|Findstr /I /C:"ProductName"^|Findstr /I /C:"Server"') do ( set srv=YES)del /q %rf%if "%srv%" EQU "YES" goto IsServer:: Workstation here



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like