ZTree.com  | ZEN  | About...  

 Index   Back

i think i found the anomaly, looks like an XP's bug   [Q]

By: Nick Williams     West Sussex, England (forum time +5 hrs)  
Date: Sep 20,2017 at 16:17
In Response to: i think i found the anomaly, looks like an XP's bug (Ryan)

> i think i found the anomaly
> i think it is an XP's bug and not a new OS's problem
> WMIC useraccount where name="%USERNAME%" get sid
> makes 3 lines below, but the 3rd line was a null string.
> S-1-5-21-1200038644-3393777314-17737942256-500
> (null string)
> XP treats a null string not as an input so SID2 takes the final value
> as
> S-1-5-21-1200038644-3393777314-17737942256-500
> on the other hand,
> win8.1 or win10 takes the null string as an input value as well, so
> they take the 3rd value as a final, i think i have to read 1 variable by
> 1 variable from FOR /F loop to take the 2nd one that both XP and new
> OS's agree on
> this kind of subtlety is too much

I think I understand the problem you're facing -- it comes down to a difference in the way XP handles the WMIC output compared to that of later Windows OSes. But it's not really a bug as such.

We can cope with that. Here's is an updated version of your script, which -- if I've done it right -- will produce the correct results in XP and later versions.

I should point out that I haven't been able to test this because I don't want to run WMIC on my computer -- I've coded it "blind", if you know what I mean.

Let us know if it works (or not).

:: ------
SET "SID1=WMIC useraccount where name="%USERNAME%" get sid"
FOR /F "DELIMS=" %%V IN ('"%SID1%"') DO (
(SET "tempWorkVar=%%V") & (IF /I "!tempWorkVar:~0,4!"=="S-1-" (SET "SID2=%%V"))

Kind regards

Thread locked

Messages in this Thread

95,097 Postings in 11,989 Threads, 350 registered users, 78 users online (0 registered, 78 guests)
Index | Admin contact |   Forum Time: Sep 20, 2020 - 4:43 am EDT  |  Hits:34,149,340  (5,896 Today )
RSS Feed