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

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 notNT
set rf="%TEMP%\ProductName_%RANDOM%.reg"
regedit /a %rf% "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
set srv=NO
for /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

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.