Wednesday, October 4, 2017

looking at data in a regkey and doing something

 i need to do "stuff" to a lot of systems. some of them i own. some i don't.  
 to make sure i do "stuff" to the ones i own - members of hell, hades or purgatory.  
 all i need to do is figure out their domain membership status.  
   
 happily, domain names are saved in a system's registry.  
 
 ..... 
 @ECHO OFF  
   
 REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" \
 /v DefaultDomainName | findstr "HELL HADES PURGATORY"   
   
 IF %ERRORLEVEL% == 1 goto end  
 IF %ERRORLEVEL% == 0 goto dosomething  
   
 goto end  
   
 :dosomething  
 @echo "Hello World"  
 pause  
   
 goto end  
   
 :end  
 @exit  
 .....

 in a nutshell, if an error is returned - that is strings defined in findstr are absent - then the script
 skips to the end and we do nothing. if the strings are present we dosomething. in this case, echo "Hello
 World" 

 the REG QUERY statement must be one line.

No comments: