ZTree.com  | ZEN  | About...  

 Index   Back

it is not quite so, still not working, still suspicious.   [Q]

By: Nick Williams     West Sussex, England (forum time +5 hrs)  
Date: Sep 19,2017 at 13:17
In Response to: it is not quite so, still not working, still suspicious. (Ryan)

Hi Ryan,

> AA=
> SET SID1=WMIC useraccount where name="%USERNAME%" get sid
> FOR /F "DELIMS=" %%V IN ('"%SID1%"') DO SET SID2=%%V
> it must have '', SID1 is similar like DIR /p, it is a command.
> the expected %SID2% would be something like
> S-1-5-21-746137067-1417001333-682574330-1003, is different from every
> other users from every other pc's
> AA=is still not working in a batch, it doesnt find the SID.

OK, I would rather not start WMIC on the computer I'm using, so I can't follow you directly, but there's an undocumented trick you can try. In AA=, in the "FOR /F" line, add an "@" symbol, as follows:-

FOR /F "DELIMS=" %%V IN ('@"%SID1%"') DO SET SID2=%%V

Does that help ? (I can't test this for you, but it will either work or not)

> BB=
> (ECHO:1)>>m:\aa.txt works
> (ECHO:11)>>m:\aa.txt works
> ECHO 1>>m:\aa.txt doesnt work
> ECHO 11>>m:\aa.txt works
> ECHO a>>m:\aa.txt works
> ECHO ab>>m:\aa.txt works
> i think it doesnt like one number, there must be something special
> about this 1>> or 2>>....

Yes, the number is definitely special in this situation ! It designates which "stream" your redirected output is going to. The standard streams are as follows:-

STDIN : Standard Input (usually the keyboard) has the number 0
STDOUT : Standard Out (usually the monitor) has the number 1
STDERR : Standard Error (similar to STDOUT, but for errors) has the number 2

The default stream (when no number has been specified) is STDOUT. So, if you wanted to redirect STDOUT to your file, you could code:-

ECHO:Hello world! >%OUT%


ECHO:Hello world! 1>%OUT%

So, going back to your BB= example:-

> ECHO 1>>m:\aa.txt doesnt work

You must use parentheses to resolve the ambiguity, as follows:-

(ECHO 1) >>m:\aa.txt

> if somehow i start to use more parenthesis like this (ECHO:%HH%) in
> nested loops, which i am already having a trouble with, OS might
> interpret them wrongly.

On the contrary, the OS will respect any number of parentheses, nested or not -- as long as they are correctly balanced. It will also make your code much easier to read and manage.

> i have to import a lot of [-HKEY_CURREN...] to delete the registries
> before i write the new ones, yes it is a very dangerous operation.

Yes, it does sound dangerous -- hope you've got good backups !

Kind regards

Thread locked

Messages in this Thread

95,078 Postings in 11,987 Threads, 350 registered users, 115 users online (0 registered, 115 guests)
Index | Admin contact |   Forum Time: Aug 15, 2020 - 10:18 am EDT  |  Hits:33,139,364  (11,193 Today )
RSS Feed