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.
November 7, 2004
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
You May Also Like