ZTree.com  | ZEN  | About...  

 Index   Back

difference between XP & Win10? IF NOT "%ALLUSERSPROFILE%"=="C:\ProgramData" way   [Q]

By: Hartmut Schneider     Germany  
Date: Oct 06,2016 at 06:10
In Response to: difference between XP & Win10? IF NOT "%ALLUSERSPROFILE%"=="C:\ProgramData" way (Ryan)

> IF NOT "%PUBLIC%"=="C:\Users\Public" GOTO WinXP
> I dont like the C: here, every variable that might distinguish from the XP contains C:

Hello Ryan,
You could use 'find', which sets the errorlevel to 0 if found, and to 1 if not found
(a feature not listed by 'help find').

You could try
echo %PUBLIC% | find "\Users\" >nul
if errorlevel 1 echo Not Win10
if errorlevel 0 echo Win10


or (query order irrelevant)
set public | find "\Users\" >nul
if %errorlevel% EQU 0 echo Win10
if %errorlevel% EQU 1 echo Not Win10


or (in 1 line)
set public | find "\Users\" >nul && echo Win10 || echo Not Win10
(tested okay on Win7; no Win10 here at work)

The Syntax of && and || is described e.g. here:
https://www.microsoft.com/resources/docu...ddocs/en-us/ntcmds_shelloverview.mspx

Hartmut

1,223 views      
Thread locked
 

Messages in this Thread

 
96,637 Postings in 12,231 Threads, 350 registered users, 46 users online (1 registered, 45 guests)
Index | Admin contact |   Forum Time: Mar 28, 2024 - 6:02 pm UTC  |  Hits:62,375,543  (27,940 Today )
RSS Feed